Hi everyone,
I am using Visual Studio 2005, Version 2.0. Coding a windows application with VB.NET.
I am trying to use a textbox (txtLogCall) to display matched results in a datagrid. I have added a bindingsource and have the dataset and tableadapter.
I have set the databinding tag of the datagrid to the field that I want to use as a parameter. The textbox is for an Caller's Name, so I have set the datagrid tag to 'EmergencyCallerIdentification' that is in the table.
I have created a SQL query:
And the code I am using is:
The error I get when I try to search in this textbox is InvalidCastException - Conversion from type 'DBNull' to type 'String' is not valid. The line of code that is highlighted for this error is 'txtLogCall.Text = dgName.Tag'
The above code did work perfectly for my other textbox search, but it requires the user to enter numeric values.
How can I resolve this?
Thanks,
Amy
I am using Visual Studio 2005, Version 2.0. Coding a windows application with VB.NET.
I am trying to use a textbox (txtLogCall) to display matched results in a datagrid. I have added a bindingsource and have the dataset and tableadapter.
I have set the databinding tag of the datagrid to the field that I want to use as a parameter. The textbox is for an Caller's Name, so I have set the datagrid tag to 'EmergencyCallerIdentification' that is in the table.
I have created a SQL query:
VB.NET:
SELECT EmergencyCallID, EmergencyResponseID, PriorityCode, EmergencyCallTime, EmergencyCallerIdentification, EmergencyPriority,
EmergencyShortDescription, Landmarks, LocationDetails, NumberOfPatients, PatientsState, EmergencyCallerCallBackNumber, EmergencyCallState
FROM [Emergency Call]
WHERE (EmergencyCallerIdentification = ?) and (EmergencyCallerIdentification LIKE '::EmergencyCallerIdentification::')
And the code I am using is:
VB.NET:
If Not txtLogCall.Text = "" Then
If IsNumeric(txtLogCall.Text) Then
MessageBox.Show("Name must be text only", "Invalid Name")
txtLogCall.Focus()
txtLogCall.BackColor = Color.Red
txtLogCall.Select(0, txtLogCall.Text.Length)
Exit Sub
Else : txtLogCall.BackColor = Color.White
DsEmergencyCall.Emergency_Call.Clear()
Try
Me.Emergency_CallTableAdapter1.Fill(DsEmergencyCall.Emergency_Call, txtLogCall.Text)
Catch ex As Exception
System.Windows.Forms.MessageBox.Show(ex.Message)
End Try
dgName.Visible = True
txtLogCall.Text = dgName.Tag
Dim parameter
parameter = dgName.Tag
Me.Emergency_CallTableAdapter1.Fill(DsEmergencyCall.Emergency_Call, parameter)
End If
End If
The error I get when I try to search in this textbox is InvalidCastException - Conversion from type 'DBNull' to type 'String' is not valid. The line of code that is highlighted for this error is 'txtLogCall.Text = dgName.Tag'
The above code did work perfectly for my other textbox search, but it requires the user to enter numeric values.
How can I resolve this?
Thanks,
Amy