CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.

YesSoftware Forums -> CodeCharge Studio -> .NET

 Question about using Parameters in SQLStatements

Print topic Send  topic

Author Message

Posts: 5
Posted: 07/26/2010, 7:09 PM

The following is the code. This is what I am trying to do. I am looping through an Excel spreadsheet and loading into the database. With Dao overriden it seems that I have a limited number of options when using the Parameter methods. I received the following error when I run this code. "System.Data.OleDb.OleDbException: Must declare the scalar variable "@Temp_File_Name".

I have working where I just build the SQL string value from the insert statement but I ran into a problem with embeded quotes. It works sort of - I have to drop all quotes out of the data.

Any suggestions would be appreciated.

DataAccessObject NewDao=Settings.newmarkdbDataAccessObject;

string sqlIns = "INSERT INTO TEMP_LEASE (Temp_File_Name,Country,City,State) VALUES (@Temp_File_Name, @Country, @City, @State)";
// string sqlIns = "INSERT INTO TEMP_LEASE (Temp_File_Name,Country,City,State) VALUES (?, ?, ?, ?)";

SqlCommand cmdIns = new SqlCommand(sqlIns, NewDao);

while (odr.Read())
country = valid(odr, 1);//Here we are calling the valid method
state = valid(odr, 2);
city = valid(odr, 3);
lstate = valid(odr, 4);
address = valid(odr, 5);
//Here using this method we are inserting the data into the database

cmdIns.Parameters.Add("@Temp_File_Name", filename);
cmdIns.Parameters.Add("@Country", country);
cmdIns.Parameters.Add("@City", city);
cmdIns.Parameters.Add("@State", lstate);



Jeff Swisher
View profile  Send private message

Add new topic Subscribe to topic   

These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit

Web Database

Join thousands of Web developers who build Web applications with minimal coding.

Home   |    Search   |    Members   |    Register   |    Login

Powered by UltraApps Forum created with CodeCharge Studio
Copyright 2003-2004 by  and YesSoftware, Inc.