Solved

How to add database table to a text field

Posted on 2006-07-11
3
180 Views
Last Modified: 2010-04-23
My questions is How to add database table to a text field when i use a button clickit should show me the table details when click
0
Comment
Question by:LeowWeeBoon
3 Comments
 
LVL 7

Accepted Solution

by:
foobarr earned 20 total points
ID: 17081106
what database server are you using?

when you say show you the details of the table do you mean the query "describe tblname" ?



I'm assuming you know how to create your connection string

public function describeTable(byval tblName as string) as dataset
   Me.myQueryString = "describe " & tblName

        myCommand = New MySqlCommand(myQueryString, myConnection)
        Try
            myDataAdapter = New MySqlDataAdapter()
            myDataAdapter.SelectCommand = myCommand
            ds = New DataSet
            myDataAdapter.Fill(ds, tblName)

            Return ds

        Catch ex As MySqlException
            MessageBox.Show("DB ERROR: Cannot Return Column See Error Trace" & Environment.NewLine & ex.Message, "DB ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1)

            ds = New DataSet
            Return ds


        End Try

end function


to call this function go

dim dSet as new dataset
dim pRow as datarow


dSet = describeTable("table1")

for each pRow in dSet.Tables("table1").rows

textbox1.text = pRow("ColumnName1").toString & "\t" & pRow("ColumnName2").tostring, etc. etc.

next

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now