Hi,
Is it possible to get a row value by giving column name using DataTable?
I have tried without success the code below.
The error
Parameter 'sp' not found in the collection.
My code C#
protected void lb1_Click(object sender, EventArgs e)
{
DataTable dt = new DataTable();
string constring = ConfigurationManager.ConnectionStrings["cn"].ConnectionString;
using (MySqlConnection con = new MySqlConnection(constring))
{
using (MySqlCommand cmd = new MySqlCommand("sp", con))
{
using (MySqlDataAdapter sda = new MySqlDataAdapter(cmd))
{
cmd.CommandTimeout = 2147483;
cmd.Connection.Open();
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Clear();
sda.Fill(dt);
string sp = dt.Rows[0]["sp"].ToString();
cmd.Parameters.AddWithValue("@sp", sp.ToString());
}
}
}
}