Solved

Insert Command for DBF

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need help on C# Linq query on object 6 63
VB.NET 2008 Populate DataModel with DataTable 44 29
Where did System.Data.Objects go? 2 28
No Data for DropDown List 2 26
It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

803 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