C# Q, reading from textboxes to a SQL DB.
Hi folks, first post so here it goes. I am getting an error when I attempt to save data from a selection of textboxes into a SQL server 2005 DB. I am using visual studio 2005, c#. Here is a sample of my code:
//Add entered data into Remote Access Table(tblRemoteAccessDetails)
protected void btnSaveRemoteAccessDetails_Click(object sender, EventArgs e)
{
string szSQL;
szSQL = string.Format("INSERT INTO tblRemoteAccessDetails (RemoteAccessID, RemoteAccessIP, RemoteAccessmethod, RemoteAccessports, RemoteAccessUsername, RemoteAccesspassword, RemoteAccesscomments) VALUES({0}, {1}, '{1}', {1}, '{1}', '{1}', '{1}'",
//Where to define ExecuteSQL?
txtNewRemoteAccessID.Text,
txtNewRemoteAccessIp.Text,
txtNewRemoteAccessMethod.Text,
txtNewRemoteAccessPorts.Text,
txtNewRemoteAccessUsername.Text,
txtNewRemoteAccessPassword.Text,
txtNewRemoteAccessComments.Text);
connection.ExecuteSQL(szSQL);
Now, my question is I am getting the error:
Error 109 'System.Data.SqlClient.SqlConnection' does not contain a definition for 'ExecuteSQL'
Where do I define this method? In the web.config file? If so any ideas on how to do so, I feel if I get this error sorted I will be close to having my project working. I have tried MSDN help and various books but they are of little help with this error.
Thanks for the feedback.