PsychoCoder
Programmer
OK,
I have a form where the user can add textboxes by clicking a linkbutton, this works perfectly. When I go to insert the text from the textboxes into the database I get a Object reference not set to an instance of an object error (keep in mind that not too long ago it worked perfectly, I took a break and came back and whamo! it dont work anymore).
The sub that enters the text into the database is:
The error seems to be the bolded line above, but when I click the "Save" button I get the error, yet when I check the database table the data is there. Can someone explain please?
Senior Qik III, ASP.Net, VB.Net ,SQL Programmer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
** Do NOT feed Code Gremlins after midnight **
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I have a form where the user can add textboxes by clicking a linkbutton, this works perfectly. When I go to insert the text from the textboxes into the database I get a Object reference not set to an instance of an object error (keep in mind that not too long ago it worked perfectly, I took a break and came back and whamo! it dont work anymore).
The sub that enters the text into the database is:
Code:
Dim iCount As Integer
For iCount = 0 To Session("NetTextBoxCount") + 2
sSQL = "INSERT INTO "
sSQL &= "dbo.Turbo_Change_Log_Items(change_log_id, change_object, change_object_changes, change_object_type, date_entered)"
sSQL &= "SELECT "
sSQL &= " @change_log_id,@change_object,@change_object_changes,1,GETDATE()"
[b]Dim txt As String = CType(Me.net_xtras.FindControl("object_" & iCount + 2), TextBox).Text[/b]
Dim txt2 As String = CType(Me.net_xtras.FindControl("changes_" & iCount + 2), TextBox).Text
Command = New SqlCommand(sSQL, Connection)
Command.Parameters.AddWithValue("@change_log_id", CType(NewId, Integer))
Command.Parameters.AddWithValue("@change_object", txt)
Command.Parameters.AddWithValue("@change_object_changes", txt2)
The error seems to be the bolded line above, but when I click the "Save" button I get the error, yet when I check the database table the data is there. Can someone explain please?
Senior Qik III, ASP.Net, VB.Net ,SQL Programmer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
** Do NOT feed Code Gremlins after midnight **
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~