Link to home
Start Free TrialLog in
Avatar of Eamon
EamonFlag for Ireland

asked on

Insert Command for DBF

What is wrong with this

            CmdDBf.Connection = CnnDBF
            CmdDBf.CommandType = CommandType.Text

            CmdDBf.CommandText = "INSERT INTO CHQS ( CHCHNO, CHBNNO, TYPE, CHAMNT, CHDATE, CHRCNC ) " & _
                                 "select ?, ?, ?, ?, ?, 0 ;"

            CmdDBf.Parameters.Add(New OleDb.OleDbParameter("@CHCHNO", OleDb.OleDbType.Double))
            CmdDBf.Parameters.Add(New OleDb.OleDbParameter("@CHBNNO", OleDb.OleDbType.Char))
            CmdDBf.Parameters.Add(New OleDb.OleDbParameter("@TYPE", OleDb.OleDbType.Char))
            CmdDBf.Parameters.Add(New OleDb.OleDbParameter("@CHAMNT", OleDb.OleDbType.Double))
            CmdDBf.Parameters.Add(New OleDb.OleDbParameter("@CHDATE", OleDb.OleDbType.Date))


            For Each divRow As DataRow In dsTempDiv.Tables("TempDiv").Rows

                Try
                    Amount = divRow("Amount")
                    HerdNo = divRow("HerdNo")
                    ChequeNo = divRow("ChequeNo")

                    CmdDBf.Parameters.Item("@CHCHNO").Value = ChequeNo
                    CmdDBf.Parameters.Item("@CHBNNO").Value = HerdNo
                    CmdDBf.Parameters.Item("@TYPE").Value = "DIV"
                    CmdDBf.Parameters.Item("@CHAMNT").Value = Amount
                    CmdDBf.Parameters.Item("@CHDATE").Value = Format(Date.Now, "")


                    CmdDBf.ExecuteNonQuery()

at execute it returns
Command is missing required clause

the missing clause is FROM

what can i do there is no table to select from as I am just adding paramaters.





ASKER CERTIFIED SOLUTION
Avatar of dstanley9
dstanley9

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Bob Learned
If you are going to use Select, then you need to specify the table that the data is coming from:

select ?, ?, ?, ?, ?, 0 From Table1

Bob
Avatar of Eamon

ASKER

Thanks dstanley9

That did the trick. Had created an insert query in access but it did not have values it just had Select.