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
hi guys i've worked through the code and have made a few advancements in that the barcode reader now works and displays the appropriate data in a DGV for the engines but the DGV for the rollin stock is not responding to the barcode reads when i scan a rollin stock barcode. here is the code please help thanks.
also could someone help me with an idea of how to copy each engine and rolling stock that is scanned into another database so i could have a log with timestamps for each engine and rolling stock that is read... would really appreciate your input thank you in advance.
Public Class Form1
Dim s As String = ""
Dim ctx As New TrainsInfoDataContext
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)
Dim rollinfo = GetRollingStockInfo(identifier)
'DisplayTrainInfo(trainInfo)
' DisplayTrainInfo(trainInfo)
End Sub
Private Function GetTrainInfo(ByVal identifier As String) As DataGridView
' LINQ To SQL code for engine
Dim engines = From trn In ctx.Train_Engines
Where (trn.Serial_Number = identifier)
Select trn
Me.Train_EngineBindingSource.DataSource = engines
End Function
Private Function GetRollingStockInfo(ByVal identifier As String) As DataGridView
' LINQ TO SQL code for rolling stock
Dim rolling = From rollstck In ctx.Rolling_Stocks
Where (rollstck.Serial_Number Like identifier)
Select rollstck
Me.Rolling_StockBindingSource.DataSource = rolling
End Function
End Class
Last edited by Eng_Mc; Aug 17th, 2012 at 12:55 AM.