Hi,
I am trying to insert some data into a SQL Server CE from a Windows Form.
I keep getting errors and I dont know why, the error code i receive is -
The ID Column in the table has this configurationThe column cannot contain null values. [Column name = ID, Table name = Pipeline ]
I think I have configured the column correctly and I would have thought that this value would be auto generated.
My code is shown below, can anyone help?
Code:Dim sqlInsertValues As String = "INSERT INTO [Pipeline] ([Reference Code],[Account Manager],[Client]," & _ "[Industry Type],[Date Approached],[Proposal Provided],[Status],[Start Date],[Follow Up Date],[Expected Revenue],[Comments]) " & _ "VALUES (@ReferenceCode,@AccountManager,@Client,@IndustryType,@DateApproached,@ProposalProvided,@Status,@StartDate,@FollowUpDate,@ExpectedRevenue,@Comments)" If SISCon.State = ConnectionState.Closed Then SISCon.ConnectionString = ConnStr SISCon.Open() End If Dim sqlInsertParameter As SqlCeCommand = New SqlCeCommand(sqlInsertValues, SISCon) With sqlInsertParameter.Parameters .AddWithValue("@ReferenceCode", refcodetb) .AddWithValue("@AccountManager", ACCTMANAGERCB) .AddWithValue("@Client", ClientTB) .AddWithValue("@IndustryType", INDUSTRYTYPECB) .AddWithValue("@DateApproached", DATEAPPROACHED.Value) .AddWithValue("@ProposalProvided", PROPOSALPROVIDEDCB) .AddWithValue("@Status", STATUSCB) .AddWithValue("@StartDate", STARTDATE.Value) .AddWithValue("@FollowUpDate", FOLLOWUPDATE.Value) .AddWithValue("@ExpectedRevenue", ExpectedRevenueFigure) .AddWithValue("@Comments", COMMENTSRTB) End With Try sqlInsertParameter.ExecuteNonQuery() SISCon.Close() MsgBox("Data commited successfully") Catch ex As Exception ' Show the exception's message. MessageBox.Show(ex.Message) ' Show the stack trace, which is a list of methods ' that are currently executing. MessageBox.Show("Stack Trace: " & vbCrLf & ex.StackTrace) End Try




Reply With Quote