K
Klaasjan
Hi,
I have a strange problem and i think the sollutions is simple, but I
don't get it.
I have the following piece of code
Dim pCommand As New System.Data.OleDb.OleDbCommand
Dim sSql As String = ""
sSql = "INSERT INTO dbo.Uitgaven ( "
sSql &= " UitgavenOmschrijving,"
sSql &= " UitgavenBedrag,"
sSql &= " UitgavenKostenPostID,"
sSql &= " UitgavenDatum"
sSql &= " ) "
sSql &= "VALUES ( "
sSql &= " @UitgavenOmschrijving,"
sSql &= " @UitgavenBedrag,"
sSql &= " @UitgavenKostenPostID,"
sSql &= " @UitgavenDatum"
sSql &= " ) "
pCommand.CommandText = sSql
pCommand.UpdatedRowSource = UpdateRowSource.Both
With pCommand
.Parameters.Add("@UitgavenOmschrijving", OleDbType.VarChar,
50, "UitgavenOmschrijving")
.Parameters.Add("@UitgavenBedrag", OleDbType.Double, 4,
"UitgavenBedrag")
.Parameters.Add("@uitgavenKostenPostID", OleDbType.Integer,
4, "UitgavenKostenPostID")
.Parameters.Add("@UitgavenDatum", OleDbType.Date, 0,
"UitgavenDatum")
End With
pCommand.Connection = pDB.Connection
For iTeller As Integer = 0 To pDS.Tables(0).Rows.Count - 1
Try
With pCommand
.Parameters("@UitgavenOmschrijving").Value =
pDS.Tables(0).Rows(iTeller).Item(3)
.Parameters("@UitgavenBedrag").Value =
pDS.Tables(0).Rows(iTeller).Item(1)
.Parameters("@uitgavenKostenPostID").Value =
pDS.Tables(0).Rows(iTeller).Item(2)
.Parameters("@UitgavenDatum").Value =
pDS.Tables(0).Rows(iTeller).Item(0)
End With
pCommand.CommandType = CommandType.Text
MessageBox.Show(pCommand.ExecuteNonQuery)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Next
I get a error "Mus declare the scalar variable "@UitgavenOmschrijving".
I have not include the primary key because that is a database thing for
me.
Can anyone give me the sollution for my problem
Thanks already
Klaasjan
I have a strange problem and i think the sollutions is simple, but I
don't get it.
I have the following piece of code
Dim pCommand As New System.Data.OleDb.OleDbCommand
Dim sSql As String = ""
sSql = "INSERT INTO dbo.Uitgaven ( "
sSql &= " UitgavenOmschrijving,"
sSql &= " UitgavenBedrag,"
sSql &= " UitgavenKostenPostID,"
sSql &= " UitgavenDatum"
sSql &= " ) "
sSql &= "VALUES ( "
sSql &= " @UitgavenOmschrijving,"
sSql &= " @UitgavenBedrag,"
sSql &= " @UitgavenKostenPostID,"
sSql &= " @UitgavenDatum"
sSql &= " ) "
pCommand.CommandText = sSql
pCommand.UpdatedRowSource = UpdateRowSource.Both
With pCommand
.Parameters.Add("@UitgavenOmschrijving", OleDbType.VarChar,
50, "UitgavenOmschrijving")
.Parameters.Add("@UitgavenBedrag", OleDbType.Double, 4,
"UitgavenBedrag")
.Parameters.Add("@uitgavenKostenPostID", OleDbType.Integer,
4, "UitgavenKostenPostID")
.Parameters.Add("@UitgavenDatum", OleDbType.Date, 0,
"UitgavenDatum")
End With
pCommand.Connection = pDB.Connection
For iTeller As Integer = 0 To pDS.Tables(0).Rows.Count - 1
Try
With pCommand
.Parameters("@UitgavenOmschrijving").Value =
pDS.Tables(0).Rows(iTeller).Item(3)
.Parameters("@UitgavenBedrag").Value =
pDS.Tables(0).Rows(iTeller).Item(1)
.Parameters("@uitgavenKostenPostID").Value =
pDS.Tables(0).Rows(iTeller).Item(2)
.Parameters("@UitgavenDatum").Value =
pDS.Tables(0).Rows(iTeller).Item(0)
End With
pCommand.CommandType = CommandType.Text
MessageBox.Show(pCommand.ExecuteNonQuery)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Next
I get a error "Mus declare the scalar variable "@UitgavenOmschrijving".
I have not include the primary key because that is a database thing for
me.
Can anyone give me the sollution for my problem
Thanks already
Klaasjan