Solved

How to add database table to a text field

Posted on 2006-07-11
3
178 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

708 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

18 Experts available now in Live!

Get 1:1 Help Now