T
TN Bella
I can't figure this out and I need some help...please!
Object reference not set to an instance of an object.
'Insert data into the account table
Sub doInsert2(Source as Object, E as EventArgs)
Dim strConn as string =
"server=abcdef;database=a_;trusted_connection=true"
Dim Mysql1 as string
Dim MyConn1 As New SqlConnection(strConn)
MySql1 = "INSERT INTO
a_p.dbo.tbl_ap_web_ce_inv_account (acct_num, cst_cntr, ref_num,
acct_amt, splr_cd, inv_numb, inv_date, user_id) VALUES ('" &
txtacctnum.Text & "','" & txtCostCntr.text & "','" & txtRefNum.text &
"','" & txtAcctAmt.text & "','" & txtSupCD.text & "','" & txtInvNum.text
& "','" & txtInvDate.text & "','" & strUser & "')"
Dim Cmd1 As New SqlCommand(MySql1, MyConn1)
MyConn1.Open()
Cmd1.ExecuteNonQuery()
MyConn1.Close()
Dim i As Int32
For i = 1 To 14
HERE: Dim MySql2 As String
MySql2 = "INSERT INTO
acct_payable.dbo.tbl_ap_web_ce_inv_account (acct_num, cst_cntr, ref_num,
acct_amt, splr_cd, inv_numb, inv_date, user_id) VALUES ("
If CType(Me.FindControl("txtAcctNum" & i),
TextBox).Text ="" Then
i +=1
GoTo HERE:
Else
MySql2 &= "'" &
CType(Me.FindControl("txtAcctNum" & i), TextBox).Text & "',"
End If
If CType(Me.FindControl("txtCostCntr" & i),
TextBox).Text ="" Then
i +=1
GoTo HERE:
Else
MySql2 &= "'" &
CType(Me.FindControl("txtCostCntr" & i), TextBox).Text & "',"
End If
If CType(Me.FindControl("txtRefNum" & i),
TextBox).Text ="" Then
i +=1
GoTo HERE:
Else
MySql2 &= "'" &
CType(Me.FindControl("txtRefNum" & i), TextBox).Text & "',"
End If
If CType(Me.FindControl("txtAcctAmt" & i),
TextBox).Text ="" Then
i +=1
GoTo HERE:
Else
MySql2 &= "'" &
CType(Me.FindControl("txtAcctAmt" & i), TextBox).Text & "',"
End If
MySql2 &= "'" & txtSupCD.text & "',"
MySql2 &= "'" & txtInvNum.text & "',"
MySql2 &= "'" & txtInvDate.text & "',"
MySql2 &= "'" & strUser & "')"
Cmd1= New SqlCommand(MySql2, MyConn1)
MyConn1.Open()
Cmd1.ExecuteNonQuery()
MyConn1.Close()
Next
finalpage(source, e)
End Sub
THANKS!
Object reference not set to an instance of an object.
'Insert data into the account table
Sub doInsert2(Source as Object, E as EventArgs)
Dim strConn as string =
"server=abcdef;database=a_;trusted_connection=true"
Dim Mysql1 as string
Dim MyConn1 As New SqlConnection(strConn)
MySql1 = "INSERT INTO
a_p.dbo.tbl_ap_web_ce_inv_account (acct_num, cst_cntr, ref_num,
acct_amt, splr_cd, inv_numb, inv_date, user_id) VALUES ('" &
txtacctnum.Text & "','" & txtCostCntr.text & "','" & txtRefNum.text &
"','" & txtAcctAmt.text & "','" & txtSupCD.text & "','" & txtInvNum.text
& "','" & txtInvDate.text & "','" & strUser & "')"
Dim Cmd1 As New SqlCommand(MySql1, MyConn1)
MyConn1.Open()
Cmd1.ExecuteNonQuery()
MyConn1.Close()
Dim i As Int32
For i = 1 To 14
HERE: Dim MySql2 As String
MySql2 = "INSERT INTO
acct_payable.dbo.tbl_ap_web_ce_inv_account (acct_num, cst_cntr, ref_num,
acct_amt, splr_cd, inv_numb, inv_date, user_id) VALUES ("
If CType(Me.FindControl("txtAcctNum" & i),
TextBox).Text ="" Then
i +=1
GoTo HERE:
Else
MySql2 &= "'" &
CType(Me.FindControl("txtAcctNum" & i), TextBox).Text & "',"
End If
If CType(Me.FindControl("txtCostCntr" & i),
TextBox).Text ="" Then
i +=1
GoTo HERE:
Else
MySql2 &= "'" &
CType(Me.FindControl("txtCostCntr" & i), TextBox).Text & "',"
End If
If CType(Me.FindControl("txtRefNum" & i),
TextBox).Text ="" Then
i +=1
GoTo HERE:
Else
MySql2 &= "'" &
CType(Me.FindControl("txtRefNum" & i), TextBox).Text & "',"
End If
If CType(Me.FindControl("txtAcctAmt" & i),
TextBox).Text ="" Then
i +=1
GoTo HERE:
Else
MySql2 &= "'" &
CType(Me.FindControl("txtAcctAmt" & i), TextBox).Text & "',"
End If
MySql2 &= "'" & txtSupCD.text & "',"
MySql2 &= "'" & txtInvNum.text & "',"
MySql2 &= "'" & txtInvDate.text & "',"
MySql2 &= "'" & strUser & "')"
Cmd1= New SqlCommand(MySql2, MyConn1)
MyConn1.Open()
Cmd1.ExecuteNonQuery()
MyConn1.Close()
Next
finalpage(source, e)
End Sub
THANKS!