Solved

How to add database table to a text field

Posted on 2006-07-11
3
187 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

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…
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

733 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