Solved

Insert Command for DBF

Posted on 2006-06-22
3
331 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Need to Modify a Script I found 5 77
.net Multiple Row Form Fields Data Entry 4 18
Form design in vb.net 7 18
Get String split 5 32
A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

707 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now