TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Glenn
NA
10
0
Cross Database queries
Aug 7 2008 2:07 PM
Hello,
I have a vbs script i am converting over to a C# application that my someone created so i can expand upon it. Everything i have redone but this last bit. Its a SQL Query that interacts with 2 different MDB files.
The SQL syntax is this:
INSERT INTO transactions IN 'C:\Trans_trim\Transact.mdb' SELECT * from transactions IN 'C:\transact.mdb' WHERE Lst_MDT < #" + DateTime.Now.AddYears(-1).Date.ToString() + "#
Here is the code I have:
string SQL1 = @"INSERT INTO transactions IN 'C:\Trans_trim\Transact.mdb' SELECT * from transactions IN 'C:\transact.mdb' WHERE Lst_MDT < #" + DateTime.Now.AddYears(-1).Date.ToString() + "#";
OleDbCommand cmd = new OleDbCommand();
OleDbConnection dbCon = new OleDbConnection();
try
{
dbCon.ConnectionString = @"Provider= Microsoft.Jet.OLEDB.4.0;Data Source='C:\Trans_trim\Transact.mdb'";
cmd.Connection = dbCon;
dbCon.Open();
cmd.CommandText = SQL1;
//cmd.ExecuteReader();
//cmd.ExecuteScalar();
cmd.ExecuteNonQuery();
}
catch (OleDbException e)
{
MessageBox.Show(e.ToString());
}
finally
{
cmd.Dispose();
dbCon.Close();
dbCon.Dispose();
}
Now no matter what type of Query Execution i use it always get the following error:
System.Data.OleDb.OleDbException: No value given for one or more required parameters.
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
at NightlyMaintiance.Form1.TrimTrans() in C:\Projects\NightlyMaintiance\NightlyMaintiance\Form1.cs:line 625
does any know what i am making a mistake on. This SQL Statement and connection string is the exact same as what is currently used in the vbs script. Thank you in advance.
Reply
Answers (
1
)
discovery of sql server instances and testing the instances for collation connection moed etc.
Database Parameters - OleDBType