[RESOLVED] System.NullReferenceException: Object reference not set to an instance of an object
i need to isnert in database and i have query liike that
Code:
str_attend = "insert into Attendees([Userid],[Attendees_name],[Attendees_telephone],[Attendees_Email] )values (" & userid & " ," & arr(0).ToString() & " , " & arr(1).ToString() & " , " & arr(3).ToString() & " )"
all values hold values in insert statment non of of them is null.
but it gives me an exception on insert statment .
Re: System.NullReferenceException: Object reference not set to an instance of an obje
First up, don't use string concatenation to insert variables into SQL code. Use parameters instead. Follow the Blog link in my signature and check out my post on ADO.NET Parameters.
That won;t help you with the immediate issue though. When you get a NullReferenceException is means that you are trying to access a member of an object that doesn't exist. To find out exactly where the issue is, debug your code. When the exception is thrown, test every expression that precedes a dot. When you find one that is Nothing, that's your issue.
Re: System.NullReferenceException: Object reference not set to an instance of an obje
Now we can't get much of this code can we?
Your problem is more likely to be on the insert code u use.
Please post some code for inserting.
Jm is faster as usual :P
Re: System.NullReferenceException: Object reference not set to an instance of an obje
yes i converted like this
str_attend = "insert into Attendees (Userid, Attendees_name, Attendees_telephone, Attendees_Email) " & _
"VALUES (" & userid & _
", '" & arr(0).ToString() & _
"', '" & arr(1).ToString() & _
"', '" & arr(0).ToString() & "')"
and its working fine