-
Dec 20th, 2010, 10:32 AM
#1
Thread Starter
Junior Member
Vb 2008 filling a dataset
Hi, I’m trying to fill a dataset, and substitute the name of the table with a value that is derived from a textbox (please forgive my terminology), I was successful with altering the query and using ifacid for the tablename (line1), but filling the dataset and the grid, (line 2) I haven’t been able to do. I’d like to replace where it says “PhisicalPlantImages” with the variable ifacid, I’m hoping this is an easy one, I spent hours yesterday googling it, so thank you very much for any help, Dan
Private Sub GetImagesFromDatabase()
Dim ifacid As String
Dim ifileid As Integer
ifacid = CType(TextBox1.Text, String)
ifileid = CType(TextBox2.Text, Integer)
Try
'Initialize SQL Server Connection
If connection.State = ConnectionState.Closed Then
connection.Open()
End If
Line 1 ‘Dim strSql As String = "Select fileid, FileName," & _
‘" FileType from PhysicalPlantImages where fileid =" & ifileid
Dim strSql As String = "Select fileid, FileName," & _
" FileType from " & ifacid & " where fileid =" & ifileid
'Initialize SQL adapter.
Dim ADAP As New SqlDataAdapter(strSql, connection)
'Initialize Dataset.
Dim DS As New DataSet()
Line 2 'Fill dataset with FileStore table.
ADAP.Fill(DS, "physicalplantimages")
'Fill Grid with dataset.
dbGridView.DataSource = (DS.Tables("physicalplantimages"))
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|