populating a datagrid with the results of a SQL statement
-
Dim strCompany As String strCompany = txtCompany.Text Dim findSQL As String findSQL = "Select * " & _ " from Client " & _ " Where name like '" & strCompany & " '%" the above is a SQL statement and i wish to populate a datagrid (either on the same page or a different one) with the results of the statement. How do i do this? Thank you!
-
Dim strCompany As String strCompany = txtCompany.Text Dim findSQL As String findSQL = "Select * " & _ " from Client " & _ " Where name like '" & strCompany & " '%" the above is a SQL statement and i wish to populate a datagrid (either on the same page or a different one) with the results of the statement. How do i do this? Thank you!
Is this question regarding VB6 or VB.net ? They way to populate the datagrid are quite different for for vb6 and .net Notorious SMC
The difference between the almost-right word & the right word is a really large matter - it's the difference between the lightning bug and the Lightning Mark Twain
Get your facts first, and then you can distort them as much as you please Mark Twain -
Dim strCompany As String strCompany = txtCompany.Text Dim findSQL As String findSQL = "Select * " & _ " from Client " & _ " Where name like '" & strCompany & " '%" the above is a SQL statement and i wish to populate a datagrid (either on the same page or a different one) with the results of the statement. How do i do this? Thank you!
Iv'e wrote an article to answer a similar question.. her is the link: http://www.codeproject.com/useritems/DataBinding.asp
-
Is this question regarding VB6 or VB.net ? They way to populate the datagrid are quite different for for vb6 and .net Notorious SMC
The difference between the almost-right word & the right word is a really large matter - it's the difference between the lightning bug and the Lightning Mark Twain
Get your facts first, and then you can distort them as much as you please Mark Twainsorry for lack of detail,and thank you for your time! its vb6, as it stands my code is: Dim strCompany As String Dim strLikeCompany As String strCompany = txtCompany.Text strLikeCompany = strCompany & "*" Dim findSQL As String findSQL = " Select ClientCode, Company, ContactName " & _ " from Client " & _ " Where Company LIKE '" & strLikeCompany & "'" Set RS = Conn.Execute(findSQL) Adodc2.RecordSource = findSQL MsgBox ("Showing Results") Me.Adodc2.Refresh Me.DataGrid1.Refresh but it displays the error "no recordset specified, command text was not set for command object." on loading and it fails to populate grid.