Array to Database

Elbob

Member
Joined
Apr 28, 2009
Messages
18
Programming Experience
1-3
Hi

I'm trying to add the values stored in an array into a database. I'm trying to use the following code.

VB.NET:
                        Dim mob(11) As String
                        mob(0) = currentRow(0).ToString
                        mob(1) = currentRow(1).ToString
                        etc
                     
                        cmd.CommandText = "INSERT INTO table (field)  
                        VALUES (mob(0))"

But i keep getting an "object reference not set to an instance of an object"

Can anyone help?

Thankyou
 
Post the whole error message if you can, it will help us to find out what is going on. Also, is that the whole code you are showing? Make sure the cmd object is something before you assign the CommandText to it.
VB.NET:
cmd = new SqlCommand()

Wasn't sure of the database type you are using so I used my defautl :) . Posting the error message will help a lot.
 

Latest posts

Back
Top