i am working on a search feature for a program i am working on and i found a tutorial online that provides some insight but the actual code, after being modified to fit my aplication, does not work. i get two different errors as of right now, one that tells me “the value of type ‘System.data.sqlclient.sqldatareader’ cannot be converted to ‘1-dimensional array of system.data.sqlclient.sqldatareader” and the other that says”argument not specified for parameter ‘array’ of ‘Public shared function… anyway i am kinda new to this and here is what i have so far. any advice?
Private Sub SearchOKButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SearchOKButton.Click
Dim TrNum
Dim dr As SqlDataReader()
TrNum = Me.SearchText.Text()
Using connection As New SqlClient.SqlConnection("Data Source=XXXXX;Initial Catalog=YYYYY;Integrated Security=True;Pooling=False;Encrypt=False"), _
cmd As New SqlClient.SqlCommand("SELECT [YYYYY] FROM (TrackingNumber) WHERE TrackingNumber = 'TrNum'", connection)
connection.Open()
dr = cmd.ExecuteReader()
While dr.AsReadOnly()
MsgBox("TrackingNumber" + "Date")
End While
connection.Close()
End Using
End Sub
There are multiple problems here…
Edited:
I assume that
TrackingNumberis the table you are querying, and that table contains columnsTrackingNumberandDate.The point of the
Usingsyntax is to automatically close the connection when the variable goes out of scope.You should probably keep your connection string in the
web.config.