I am 2 days old in asp.NET. I had the option to do one of my home assignments in asp.NET and I thought it would be fun. It's not been as scary as I thought. Still, I have troubles debugging my queries. I can catch errors with try-catch block, obviously, but I don't know how to get a detailed error message.
If I don't use the try-catch block, an error in the query halts the website and displays a 1-line error message in Visual Studio (if I have it open)

Since I'm using OleDb, I suspect I have to work with OleDbException or OleDbError, but I can't get it syntactically correct.

Code below works fine, without errors. Problems arise with other queries, which I'm sure are correct.

string v1 = Request["v1"];                                    
string v2 = Request["v2"];
sql2 = "INSERT INTO table(one, two) VALUES('" + v1 + "', '" + v2  + "')";

System.Data.OleDb.OleDbConnection con2 = new System.Data.OleDb.OleDbConnection();
con2.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/Users/BB/Desktop/Database.mdb";
OleDbCommand command = new OleDbCommand(sql2, con2);

	// detailed error message here?

you are two times using command.ExecuteNonQuery() in your code...please correct

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.