Home > Enterprise >  Xamarin android development, direct access to the SQL server database, the fill can query records. B
Xamarin android development, direct access to the SQL server database, the fill can query records. B

Time:09-20

Xamarin android development, direct access to the SQL server database, SqlCommandBuilder way, can the fill query records,
But want to delete, modify, add, when performing the UPDATE is always an error,
Such as the following code
String this="select * from pdaczb";
SqlConnection cn=new SqlConnection (" Server=192.168.50.191; The Database=tjcy; User ID=sa; Password=123 STLTW ");
SqlDataAdapter da=new SqlDataAdapter (this, cn);
SqlCommandBuilder CMD=new SqlCommandBuilder (da);
The DataSet ds=new DataSet ();
Da. The Fill (ds);
//ds. Tables [0]. Rows [0] [" titile_id "]="asdf";//change the line
Ds. Tables [0]. Rows [1]. The Delete ();//remove the line
/* DataRow Dr=dt. NewRos ();
Dr [0]="asdf";
Dr [1]="JKL";
.
Dt. Rows. The Add (Dr);//the new line
*/
Try
{
Da. Update (ds);//update the database
}
Catch
{
Toast. MakeText (this, "er", ToastLength. Long), Show ();
}
Only perform a delete command is wrong

CodePudding user response:

Don't see the specific error failure can not directly answer, but there may be the easiest way to add, delete, add don't operate at the same time, choose the single class such as add, add only one field, each troubleshooting problems came out,