Tree View and Database Pls help!!

girl

Active member
Joined
Jun 11, 2007
Messages
25
Programming Experience
Beginner
Hihi,

i would like to seek for help for a problem.

Currently i have a treeview design with table names from SQL 2000.
what i want to do is to click on the table name located @ the treeview and my data will be displayed using a datagrid.

is that possible??

these are my codes

VB.NET:
Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect

Dim constring As String = "Driver={SQL Server};Server=localhost;Database=statistics;"

Dim conn As New Odbc.OdbcConnection(constring)

Dim mycommand As Odbc.OdbcCommand = conn.CreateCommand()

Dim tablename As String = "" & e.Node.Text

conn.Open() 'for database

Dim od As New OdbcDataAdapter("SELECT * from '" & _
tablename & "' ", conn)
Dim ds As New DataSet


ds.Tables.Add("'" & _
tablename & "'")
ds.Tables.Add("textfile")
[COLOR="Purple"]od.Fill(ds, "'" & _
tablename & "'")[/COLOR]
 DataGridView1.DataSource = ds.Tables("'" & _
tablename & "'")
conn.Close()

when i run the program, there was an error @ the colored line
od.Fill(ds, "'" & _
tablename & "'").

they prompt me line 1 INVALID SYNTAX NEAR "acb" where acb is my table name.

iS this my dataset problem??

thnx for helping!!
 
Back
Top