jaguRita

jaguRita

  • NA
  • 40
  • 0

SQLDataAdapter - Error

Aug 24 2007 2:30 AM

Hello all,

I have written code for Updtaing the user information for a specific row.But when i run this code i am getting Run time Exception "InvalidOperationException" And Message "Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information."
Am i doing anything wrong in code?

public static DataSet getUserInfo()
        {
            DataSet ds = new DataSet();
            string connectionstring = " ";
            SqlConnection con = new SqlConnection(connectionstring);
            SqlCommand cmd = new SqlCommand(@"select FirstName from User_Info",con);
            SqlDataAdapter sda = new SqlDataAdapter(cmd);
            SqlCommandBuilder scb = new SqlCommandBuilder(sda);
            sda.Fill(ds);
            //Before Change
           Console.WriteLine("\n\t"+ds.Tables[0].Rows[1]["FirstName"]);
            ds.Tables[0].Rows[1]["FirstName"] = "Sam";
            //Update in Database
            sda.Update(ds);
            //After Change
            Console.WriteLine("\n\t" + ds.Tables[0].Rows[1]["FirstName"]);
            return ds;

}

Please help me out to resolve this problem.And please tell where i get tutorials for this Ado.
Thanks 4 ur help.