Witam
SqlCeConnection myconnection = new SqlCeConnection("Data Source=data.sdf");
string insert_command = "INSERT INTO main_table (list_name) values(@kname)";
SqlCeCommand in_command = new SqlCeCommand(insert_command, myconnection);
in_command.Parameters.AddWithValue("@kname", name);
myconnection.Open();
in_command.ExecuteNonQuery();
myconnection.Close();
string select_id = "select id from main_table, where list_name like '@name';";
int last_list_id;
SqlCeCommand sel_id=new SqlCeCommand(select_id, myconnection);
sel_id.Parameters.AddWithValue("@name",name);
myconnection.Open();
last_list_id=Convert.ToInt32(sel_id.ExecuteScalar());
myconnection.Close();
Wszystko byłoby ok, ale coś mi tu jednak się psuje w tym miejscu:
last_list_id=Convert.ToInt32(sel_id.ExecuteScalar());
W tabeli w bazie danych istnieje kolumna id w wierszu z unikalną wartością typu string list_name, chcę przypisać jedną krotkę z tej listy z wartością typu int do zmiennej w programie, ale wyskakuje mi że "There was an error parsing the query. [Toklen line number =1, Token line offset =28, Token in error = where]"
Domyślam się, że prawdopodobnie napisałem źle selecta, ale nie bardzo wiem jak to zrobić inaczej.
O co tu chodzi?