Need sample - VB .NET reading Northwind

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I have creatd a vb .net app that scans a barcode and displays the decoded
value on the form. I have also created a connection to Northwind and can
retrieve data. I need an example of how to take the scanned in value (which
I can get), put it in a Select statement, call Northwind, and then grab a
value on that row and display it on the form. I don't know how to use the
scanned value as a variable in the Select statement, and I don't know how to
put it on the form once I get it back from the db.
Any help is appriciated,
Thanks,
Steve
 
Well, here is what I did. It works, but if it goes against every "best
practice" for WinCE device programming, please jump in. . . I created a
table called products.

Dim mySelectQuery As String = "SELECT ProductName FROM Products Where
ProductID = " & dcdData
Dim myConnection As New SqlConnection("User
ID=sa;Password=saremote;Initial Catalog=PSC;Data Source=MIKEM;")
Dim myCommand As New SqlCommand(mySelectQuery, myConnection)
myConnection.Open()
Dim myReader As SqlDataReader
myReader = myCommand.ExecuteReader()
Me.txtName.Text = " "
While myReader.Read()
Me.txtName.Text = myReader.GetString(0)
'Console.WriteLine((myReader.GetString(0)))
End While
myReader.Close()
myConnection.Close()
 
Well, here is what I did. I created a small table called products. If this
code goes against every "best practice" for WinCE device programming, please
jump in. . .

Dim mySelectQuery As String = "SELECT ProductName FROM Products Where
ProductID = " & dcdData
Dim myConnection As New SqlConnection("User
ID=sa;Password=pswrd;Initial Catalog=PSC;Data Source=MIKEM;")
Dim myCommand As New SqlCommand(mySelectQuery, myConnection)
myConnection.Open()
Dim myReader As SqlDataReader
myReader = myCommand.ExecuteReader()
Me.txtName.Text = " "
While myReader.Read()
Me.txtName.Text = myReader.GetString(0)
End While
myReader.Close()
myConnection.Close()
 
Back
Top