all groups > dotnet compact framework > may 2007 >
You're in the

dotnet compact framework

group:

Need help copying listbox items to database table


Need help copying listbox items to database table Loogie
5/30/2007 8:30:15 AM
dotnet compact framework: I am using VB.Net 2005 Compact Framework with SQL CE Server.

I am attempting to add the entire contents of a listbox to a SQL CE
Server database but my code is throwing an error and I do not know how
to fix it.

Here is my code:

'Create product species table
sqlCreateTable.CommandText = "CREATE TABLE prodspecies(s_item
int IDENTITY(1,1) PRIMARY KEY NOT NULL, s_code NVARCHAR(10) NOT NULL,
s_link NVARCHAR(3) NOT NULL, s_verify NVARCHAR(3) NULL)"
sqlCreateTable.ExecuteNonQuery()

Dim X As Integer
X = 0

Dim sqlInsertRow2 As SqlCeCommand = ssceconn.CreateCommand()
Do Until X = lstOut.Items.Count
Dim strsqlSPEC As String = "INSERT INTO prodspecies(s_code,
s_link) VALUES('" & lstIn.Items.Add(lstOut.Items.Item(X)) & "', '" &
cboCode.SelectedItem.ToString & "')"
sqlInsertRow2.ExecuteNonQuery()
X = X + 1
Loop

Details of error:

System.InvalidOperationException was unhandled
Message="Prepare: CommandText property has not been initialized"

Error occurs on line: sqlInsertRow2.ExecuteNonQuery()

Please help me fix this.

Thanks

Re: Need help copying listbox items to database table Loogie
5/30/2007 8:37:09 AM
[quoted text, click to view]

DOH...nevermind I got it. strsqlSPEC and sqlInsertRow2 does not compute

AddThis Social Bookmark Button