Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 3145

No Record Found message vb.net+Sql 2012

$
0
0
Hello . . . i use this code for searching in sql database what i want is where should i put the message "No Record Found "[code="vb"] If TextBox1.Text = "" Then MsgBox("Please Enter License Number ", MsgBoxStyle.Critical, "Error") Exit Sub End If Dim sqlStr As String = "SELECT * FROM MonitoringReports WHERE EmployeeID = '" & TextBox9.Text & "' and LicensesNumber='" & TextBox1.Text & "'" Dim dataAdapter As New SqlDataAdapter(sqlStr, con) dataAdapter.Fill(dt) If dt.Rows.Count < 0 Then MsgBox("No Record Found", MsgBoxStyle.Critical, "Error") Else For i As Integer = 0 To (dt.Rows.Count - 1) rowIndex = i TextBox8.Text = CStr(dt.Rows(rowIndex)("EmployeeName")) TextBox9.Text = CStr(dt.Rows(rowIndex)("EmployeeID")) DateTimePicker2.Value = CStr(dt.Rows(rowIndex)("DateOfEntry")) TextBox1.Text = CStr(dt.Rows(rowIndex)("LicensesNumber")) TextBox2.Text = CStr(dt.Rows(rowIndex)("LicensesName")) TextBox5.Text = CStr(dt.Rows(rowIndex)("LicensesType")) ComboBox6.Text = CStr(dt.Rows(rowIndex)("LicensesCase")) ComboBox1.Text = CStr(dt.Rows(rowIndex)("Location")) ComboBox2.Text = CStr(dt.Rows(rowIndex)("Street")) TextBox3.Text = CStr(dt.Rows(rowIndex)("NearOrNextTo")) ComboBox3.SelectedValue = CStr(dt.Rows(rowIndex)("ActionType")) ComboBox7.SelectedValue = CStr(dt.Rows(rowIndex)("ActionNumber")) ComboBox5.SelectedValue = CStr(dt.Rows(rowIndex)("FineOrWarrningType")) TextBox4.Text = CStr(dt.Rows(rowIndex)("Notes")) DateTimePicker1.Value = CStr(dt.Rows(rowIndex)("DateOfFollow")) Next End If[/code]Kind Regards

Viewing all articles
Browse latest Browse all 3145

Trending Articles