|
-
Aug 15th, 2012, 09:28 PM
#1
Thread Starter
Junior Member
Linq to sql help
hi please need some help with LINQ TO SQL trying to use it as i read a barcode to query the required row fro the database in real time. icant seem to see any errors in the code but the code shows nothing in the DGV when i run it please help.
Public Class Form1
Dim s As String = ""
Dim ctx As New TrainsInfoDataContext
'Private Sub TextBox1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Brcd.KeyPress
' If Asc(e.KeyChar) = 13 Then
' TextBox1.Text = (s + vbCrLf)
' s = ""
'Else
' s = s + e.KeyChar
'End If
'End Sub
'Private Sub ProcessTrainIdentifier(ByVal identifier As String)
' For now, just log that we saw an identifier
' ListBox1.Items.Add(String.Format("Saw identifier {0} at {1}", identifier, DateTime.Now))
'End Sub
Private Sub Brcs_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Brcd.KeyDown
If e.KeyCode = Keys.Return Then
ProcessTrainIdentifier(Brcd.Text)
Brcd.Clear()
End If
End Sub
Private Sub ProcessTrainIdentifier(ByVal identifier As String)
Dim trainInfo = GetTrainInfo(identifier)
'DisplayTrainInfo(trainInfo)
' DisplayTrainInfo(trainInfo)
End Sub
Private Function GetTrainInfo(ByVal identifier As String) As String
' LINQ To SQL code goes here
Dim engines = From trn In ctx.Train_Engines
Where trn.Serial_Number Like identifier
Select trn
Me.Train_EngineBindingSource.DataSource = engines
'Dim rolling_stock = From rollstck In ctx.Rolling_Stocks
'Where(RollStck.Serial_Number Like identifier)
' Select RollStck
End Function
Private Sub DisplayTrainInfo(ByVal trainInfo As TrainsInfoDataContext)
' Write the data in trainInfo to the UI
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|