Question:
how to use insert query in asp.net for ms access database? can any one say?
ram
2010-03-08 09:26:37 UTC
con = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; Data Source=database1.mdb;")
con.Open()
cmd = New OleDbCommand("insert into number values ('name','03/03/10',str)", con)
cmd.ExecuteNonQuery()
con.Close()
i am using the database Ms-access contains table named number it has values are name as text,date as date/time, value as integer..
if i execute the above query that gives Syntax error in INSERT INTO statement. error
how can rectify that problem?
can anyone help me?

thanks for all
Four answers:
2010-03-08 09:59:14 UTC
I think you have variable str already declared and intialized to some integer value..

If thats the case than use this line:

cmd = New OleDbCommand("insert into number values ('name','03/03/10',"+str+")", con)



Even name appears to be a variable in your program.

If its true as well , than use this instead:

cmd = New OleDbCommand("insert into number values ('"+name+"','03/03/10',"+str+")", con)
lue
2016-05-31 11:50:41 UTC
If the transaction in the second database is approved, and it is being approved again, then you need to have a reference link between the 2 databases so that the original list of transactions can exclude records that already exist in the second database. By not doing this, then you are allowing multiple users to approve the same transaction. You need to prevent that from happening. Even if 2 users are approving the same transaction at the same time, one of them must execute first, and the second one must reject. To do that, you need to change the Select clause of your INSERT statement to LEFT JOIN to the destination table WHERE the transactionID is null. INSERT (.......) SELECT ........ FROM Array a LEFT JOIN Target t ON t.ID=a.ID WHERE t.ID IS NULL That will exclude any transaction that already exists in the target table. It sounds like you have an awkward system design there. You should be able to use replication or log shipping to keep the second database current. Good luck.
?
2010-03-08 20:39:13 UTC
Hello

This is JARC InfoTech, providing service is Website/ Application Development for the last 4 year.

Our professionals have very rich experience in ASP.NET/SQL/SQL SERVER.

Please send us question with more details at following email ID to get a solution



email ID: rex@jarcinfotech.com

http://www.jarcinfotech.com
Pete S
2010-03-08 09:29:55 UTC
str is not defined, you either want 'str' or @str and add a parameter to the cmd.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...