Solved

Insert Command for DBF

Posted on 2006-06-22
3
340 Views
Last Modified: 2008-02-01
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.





0
Comment
Question by:Eamon
3 Comments
 
LVL 25

Accepted Solution

by:
dstanley9 earned 500 total points
ID: 16962079

try this:

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

Expert Comment

by:Bob Learned
ID: 16963083
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
0
 
LVL 1

Author Comment

by:Eamon
ID: 16967009
Thanks dstanley9

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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question