Hi, I am using VB.Net in Visual Studio 2008 with a connected SQL Server Compact Database but for some reason I can not get a record to insert into my Database from my Windows Form.
I have used the data connection on the form already to populate a couple of combo boxes but when it comes to commiting the data the sub runs through but there is no additional data in my database.
my code is as follows
Teh table only contains these 4 fields and another field which is an automatically generated number called nbrQuoteID
All of the fields are number fields but I have tried sending them as text to see if it made a difference (Threw up an error) but it didn't.
I have used the data connection on the form already to populate a couple of combo boxes but when it comes to commiting the data the sub runs through but there is no additional data in my database.
my code is as follows
Code:
Private Sub cmdAddQuote_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAddQuote.Click Dim cnData As New SqlCeConnection Dim cdData As SqlCeCommand Dim strsql As String strsql = "INSERT INTO HS_QuoteDetail (nbrRecordNbr, nbrItemNbr, nbrItemCount, CurCost) VALUES ('" & Me.txtJobID.Text strsql = strsql & "', '" & Me.ItemIDNbr.Text & "', '" & Me.nbrUnits.Text & "', '" & Me.curSubTotal.Text & "');" cnData.ConnectionString = "data source = Database1.sdf; Persist Security Info = False" If cnData.State = ConnectionState.Closed Then cnData.Open() End If cdData = New SqlCeCommand(strsql, cnData) 'cdData.ExecuteNonQuery() cdData.ExecuteNonQuery() MsgBox("Run") Me.nbrUnits.Focus.Equals(True) cnData.Close() End Sub
All of the fields are number fields but I have tried sending them as text to see if it made a difference (Threw up an error) but it didn't.
Comment