So the answer was easier than I thought
WHERE Company= '" + CompanyHeader.Text + "' AND TrailerNumber='" + TrailerTxtBox.Text + "'")
Thanks anyway
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi, I am using VB.NET win forms. I have multiple TextBoxes on my form and I am fetching data from a MySQL database like so. It does work I just want to add an extra clause to check.
Try
mySQLcon = New MySqlConnection("Data Source=My IP; userid=My Username; password=My Password; database=Database name")
cmd.Connection = mySQLcon
cmd.CommandText = ("select TrailerMOTDate,TrailerServiceDate,TrailerLocationMOT,TrailerLocationService FROM TrailerNumbersTbl WHERE TrailerNumber='" + TrailerTxtBox.Text + "'")
mySQLcon.Open()
Dim lrd As MySqlDataReader = cmd.ExecuteReader()
If lrd.HasRows Then
lrd.Read()
MotDateTxtBox.Text = lrd.GetValue(0).ToString()
ServiceDate.Text = lrd.GetValue(1).ToString()
MOTLocation.Text = lrd.GetValue(2).ToString()
ServiceLocation.Text = lrd.GetValue(3).ToString()
mySQLcon.Close()
Else
MsgBox("Select a trailer first")
End If
Catch ex As Exception
MessageBox.Show("Hmm you have come across an error ")
Finally
End Try
I want to add an additional check i.e. I have the company name in a label on my form the company label is called CompanyName.Text
Where I have got this
WHERE TrailerNumber='" + TrailerTxtBox.Text + "'")
I want add an AND CompanyName.Text which would help make it more secure
Can someone help me with this?
Thanks
So the answer was easier than I thought
WHERE Company= '" + CompanyHeader.Text + "' AND TrailerNumber='" + TrailerTxtBox.Text + "'")
Thanks anyway