モノドロイドアプリケーションからSQLサーバーにWebサービスを介してデータを保存したい。
monodroid==>Webサービス==>SQLサーバー
実際、私はWebサービスを介してSQLサーバーでasp.netを試しました。このアプローチでは問題なく動作します。SQLサーバーに挿入されたデータ。
asp.net==>Webサービス==>SQLサーバー。
しかし、monodroidに対してこれと同様の方法を試したところ、データはまだSQLServerデータベースに保存されていません。
Webサービスのコードは次のとおりです。
SqlConnection conn = new SqlConnection(@"Data Source=DINESH-PC\SQLEXPRESS;Initial Catalog=remotedb;Integrated Security=True");
SqlCommand com;
public Service1 () {
//Uncomment the following line if using designed components
//InitializeComponent();
}
[WebMethod]
public string insert(string name)
{
com = new SqlCommand("insert into dinesh values('" + name + "')", conn);
conn.Open();
com.ExecuteNonQuery();
conn.Close();
return "Hello World";
}
}
これがmonodroidの私のコードです
public class Activity1 : Activity
{
localhost.Service1 suresh = new localhost.Service1();
string dinesh;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
// Get our button from the layout resource,
// and attach an event to it
Button button = FindViewById<Button>(Resource.Id.MyButton);
EditText e1=FindViewById<EditText>(Resource.Id.editText1);
button.Click += delegate {
dinesh = suresh.insert(e1.Text);
};
}
}
}
助けてください、コーディングで変更する必要があるものはありますか、またはmonodroidでWebサービスにアクセスするために設定を変更する必要がありますか?