Hi, can someone look this over and help me find out why I keep getting the Object reference error. I have looked at the HTML and the names match exactly. Basically what I am trying to do is insert multiple records into the database using a data entry form. My form contains a datagrid with text boxes for the variables. Any input would be appreciated.
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
Dim _MID, _Desc, _Actual, _Target, _Thresh, _PED As TextBox
Dim aMID, aDesc, aActual, aTarget, aThresh, aPED As String
Dim MyRow As DataGridItem
Dim StringSQL As String
Dim counter As Integer
For counter = 0 To dgTrans.Items.Count - 1
MyRow = dgTrans.Items(counter)
_Desc = CType(FindControl("tbAddDesc"), TextBox)
_Actual = CType(FindControl("tbAddActual"), TextBox)
_Target = CType(FindControl("tbAddTarget"), TextBox)
_Thresh = CType(FindControl("tbAddThresh"), TextBox)
_MID = CType(FindControl("tbAddMID"), TextBox)
_PED = CType(FindControl("tbDate"), TextBox)
If Not _MID.Text = "" Then
aMID = CType(_MID.Text, String)
Else
aMID = "0"
End If
If Not _Desc.Text = "" Then
aDesc = CType(_Desc.Text, String)
Else
aDesc = "0"
End If
If Not _Actual.Text = "" Then
aActual = CType(_Actual.Text, String)
Else
aActual = "0"
End If
If Not _Target.Text = "" Then
aTarget = CType(_Target.Text, String)
Else
aTarget = "0"
End If
If Not _Thresh.Text = "" Then
aThresh = CType(_Thresh.Text, String)
Else
aThresh = "0"
End If
If Not _PED.Text = "" Then
aPED = CType(_PED.Text, String)
Else
aPED = "0"
End If
StringSQL = "INSERT INTO Transcription1 (MeasureId, Description, Acutal, Target, Threshold, PED) VALUES ("
StringSQL = StringSQL & "'" & aMID & "',"
StringSQL = StringSQL & "'" & aDesc & "',"
StringSQL = StringSQL & "'" & aActual & "',"
StringSQL = StringSQL & "'" & aTarget & "',"
StringSQL = StringSQL & "'" & aThresh & "',"
StringSQL = StringSQL & "'" & aPED & "')"
ExecuteStatement(StringSQL.ToString)
Next counter
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
Dim _MID, _Desc, _Actual, _Target, _Thresh, _PED As TextBox
Dim aMID, aDesc, aActual, aTarget, aThresh, aPED As String
Dim MyRow As DataGridItem
Dim StringSQL As String
Dim counter As Integer
For counter = 0 To dgTrans.Items.Count - 1
MyRow = dgTrans.Items(counter)
_Desc = CType(FindControl("tbAddDesc"), TextBox)
_Actual = CType(FindControl("tbAddActual"), TextBox)
_Target = CType(FindControl("tbAddTarget"), TextBox)
_Thresh = CType(FindControl("tbAddThresh"), TextBox)
_MID = CType(FindControl("tbAddMID"), TextBox)
_PED = CType(FindControl("tbDate"), TextBox)
If Not _MID.Text = "" Then
aMID = CType(_MID.Text, String)
Else
aMID = "0"
End If
If Not _Desc.Text = "" Then
aDesc = CType(_Desc.Text, String)
Else
aDesc = "0"
End If
If Not _Actual.Text = "" Then
aActual = CType(_Actual.Text, String)
Else
aActual = "0"
End If
If Not _Target.Text = "" Then
aTarget = CType(_Target.Text, String)
Else
aTarget = "0"
End If
If Not _Thresh.Text = "" Then
aThresh = CType(_Thresh.Text, String)
Else
aThresh = "0"
End If
If Not _PED.Text = "" Then
aPED = CType(_PED.Text, String)
Else
aPED = "0"
End If
StringSQL = "INSERT INTO Transcription1 (MeasureId, Description, Acutal, Target, Threshold, PED) VALUES ("
StringSQL = StringSQL & "'" & aMID & "',"
StringSQL = StringSQL & "'" & aDesc & "',"
StringSQL = StringSQL & "'" & aActual & "',"
StringSQL = StringSQL & "'" & aTarget & "',"
StringSQL = StringSQL & "'" & aThresh & "',"
StringSQL = StringSQL & "'" & aPED & "')"
ExecuteStatement(StringSQL.ToString)
Next counter