Below is the code for which am getting
must declare scalar variable @connection
error. I don't know where I am going wrong. Please guide
protected void LinkButton1_Click(object sender, EventArgs e)
{
string connection = Drpconn.SelectedItem.Text;
using (OdbcConnection con = new OdbcConnection("DSN=Sqltesting;UID=user1;PWD=test@123;Integrated Security=no;"))
{
using (OdbcCommand cmd = new OdbcCommand("INSERT INTO TblConfigure(Connection,Server,DbName,UserID,Password,Connection_Name,Port,Service_ID) VALUES (@Connection, @Server , @DbName,@UserID,@Password,@ConnectionName,@Port,@ServiceID)", con))
{
con.Open();
cmd.Parameters.AddWithValue("@Connection", connection);
cmd.Parameters.AddWithValue("@Server", TxtServer.Text);
cmd.Parameters.AddWithValue("@DbName", DrpDbName.SelectedItem.Text);
cmd.Parameters.AddWithValue("@UserID", TxtUsr.Text);
cmd.Parameters.AddWithValue("@Password", TxtPass.Text);
cmd.Parameters.AddWithValue("@ConnectionName", Txtconnname.Text);
cmd.Parameters.AddWithValue("@Port", TxtPort.Text);
cmd.Parameters.AddWithValue("@ServiceID", TxtService.Text);
cmd.ExecuteNonQuery();
}
} // closes the connection
Response.Redirect("LoginPL.aspx");
}