slim Posted May 26, 2004 Posted May 26, 2004 Hi, Just a quick question about the best way to display data from a SQL query on a form. The following code works fine and lists the records in a listbox, but what I would like to do is display the data in a datagrid or flexigrid, but I have not been able to work out how to do it. Can anyone point me in the right direction. Thanks in advance for any help Slim Dim conA As New Odbc.OdbcConnection Dim strSql As String = "select * from product" conA.ConnectionString = "DSN=" & txtDsn.Text & ";Password=" & txtPassword.Text & ";User ID=" & txtUsername.Text conA.Open() Dim mycommand As New OdbcCommand(strSql, conA) Dim myODBCreader As OdbcDataReader = mycommand.ExecuteReader While myODBCreader.Read ListBox1.Items.Add(myODBCreader("Bin")) End While conA.Close() myODBCreader.Close() mycommand.Dispose() Quote
wessamzeidan Posted May 26, 2004 Posted May 26, 2004 If your application is a windows application, then you have to use a datatable instead of a datareader, but if its a web application you can use this DataGrid1.DataSource=myODBCreader DataGrid1.DataBind() Quote Proudly a Palestinian Microsoft ASP.NET MVP My Blog: wessamzeidan.net
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.