0

Hello,

I am developing a program in VB.Net and ASP.Net to allow a user to type in a code in a textbox and when they click search, a list of records with a code matching the code typed in are retrieved from an SQL Server Express database.

At the moment, I type in a code and click search, and my listbox then gets populated with 3 lines, each one saying:

'System.Data.Common.DataRecordInternal'

I was wondering if anybody would be able to explain this to me at all?

My code is as follows:

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
            
     Dim sqlConn As New SqlConnection
     Dim sqlCmd As New SqlClient.SqlCommand
     Dim sqlReader As SqlDataReader
            
     If TextBox1.Text = "" Then
         MsgBox("A centre code needs to be provided...")
     End If
            
     If TextBox1.Text <> "" Then
                            
         'Telling the system the location of the database.
         sqlConn.ConnectionString = "server=server;Initial Catalog=dbname;Trusted_Connection=yes"

         'Here we are opening the connection to the database.
         sqlConn.Open()
                            
         'This is to say that sqlCmd is a stored procedure.
         sqlCmd.CommandType = System.Data.CommandType.StoredProcedure
                        
         'This is creating the command to execute the stored procedure based on the information given in the connection string.
         sqlCmd = sqlConn.CreateCommand
            
         'The command is triggered to execute the stored procedure which grabs all information for the specific centre.
                sqlCmd.CommandText = "exec GetAllInformation '" & TextBox1.Text & "' "
                             
         sqlReader = sqlCmd.ExecuteReader()
                
         'This grabs the details for the specific centre from the database using the data reader.
         ListBox1.DataSource = sqlReader
         ListBox1.DataBind()
                                
         'This is closing the connection to the database once we have finished with it.
         sqlConn.Close()
                
         End If
                
End Sub

If anyone can advise, it would be greatly appreciated.

Many thanks,

Dan

Edited by dwinn: n/a

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by Pgmer
0

Loop through data reader and get the items you want to assign to list box else
get the result into dataset and then assign the dataset as datasource to ur listbox.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.