denkyirane 0 Newbie Poster

Hi PPL
I am working on a mobile application with VB.NET. I have created a table in SQLServerCE <tblFertilizer> in a database <Packhouse.sdf>
Now i am trying to insert data into the table upon a button click event, but i get an "error parsing query" issue on the line where i execute the query

this is the entire code i am using

Main() // my main

Dim dtDate As Date
Dim section, type, ingredient, method, applied, authorised, weight, qty As String
Dim str As String


dtDate = dtpFertilizer.Value.ToString
section = cmbSection.SelectedItem.ToString
type = cmbFertType.SelectedItem.ToString
weight = txtWeight.Text.ToString
ingredient = cmbIngredient.SelectedItem.ToString
qty = txtQty.Text.ToString
method = cmbMethod.SelectedItem.ToString
applied = cmbAppliedBy.SelectedItem.ToString
authorised = cmbAuthorized.SelectedItem.ToString

str = ""
str = str & "Insert Into tblFertilizer(recno, dDate, section, type, weight, ingredient, qty, method, applied, authorised)"
str = str & " values(" & dtDate & "," & section & "," & type & "," & weight & "," & ingredient & "," & qty & "," & method & "," & applied & "," & authorised & ")"


cmdPackhouse = New System.Data.SqlServerCe.SqlCeCommand(str, connPackhouse)
cmdPackhouse.CommandType = CommandType.Text
cmdPackhouse.ExecuteNonQuery() // this is where error occurs

connPackhouse.Close()

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.