sarath jasrin

sarath jasrin

  • NA
  • 5
  • 2.7k

FaultException wasunhandled

Feb 10 2014 1:31 AM
I'm new to both WP7 and web service. I
created one login page in WP7 and created one
web service.I need to store user detail in
access databse through web service. I
successfully consumed web service in WP7 but
it show error during runtime 'FaultException
was unhandled' in the referance.cs file.

App_code/Services.cs (webservice code):
[WebMethod]
public string userDetail( int
id, string uname, string pwd, int
age, string gender, string place,
string country)
{
OleDbConnection con;
OleDbCommand cmd;
con = new OleDbConnection
( "Provider=Microsoft.ACE.OLEDB.12.0
;Data Source=C:\\Users\\Amma\
\Documents\\UserDetail.accdb" );
con.Open();
cmd = new OleDbCommand
( "insert into login
(id,uname,pwd,age,gender,place,
country)values(?,?,?,?,?,?,?)" ,
con);
cmd.Parameters.Add( "?" , id);
cmd.Parameters.Add
( "?" ,uname);
cmd.Parameters.Add( "?" ,
pwd);
cmd.Parameters.Add( "?" ,
age);
cmd.Parameters.Add( "?" ,
gender);
cmd.Parameters.Add( "?" ,
place);
cmd.Parameters.Add( "?" ,
country);
cmd.ExecuteNonQuery();
con.Close();
return uname;
}

MainPage.xaml.cs (WP7)
string name, pwd, gender, place,
country;
int age, id = 0;
private void
BtnRegister_Click( object sender,
RoutedEventArgs e)
{
ServiceReference1.
ServiceSoapClient ws = new
ServiceReference1.ServiceSoapClient
();
ws.userDetailCompleted
+= new EventHandler&
ltuserDetailCompletedEventArgs&gt
(ws_userDetailCompletd);
ws.userDetailAsync(id,
name, pwd, age, gender, place,
country);
}
void ws_userDetailCompletd
( object
sender,userDetailCompletedEventArgs
e)
{
id =
Convert.ToInt32(textBoxId.Text);
pwd =
Convert.ToString(textBoxPwd.Text);
name =
Convert.ToString(textBoxName.Text);
age =
Convert.ToInt32(textBoxAge.Text);
if
(radioBtnMale.IsChecked == true )
{
gender =
"Male" ;
}
else
gender =
"Female" ;
place =
Convert.ToString(textBoxPlace.Text);
country =
Convert.ToString
(textBoxCountry.Text);
MessageBox.Show
( "successfully Registered" );
}
referance.cs

public Test.ServiceReference1.
userDetailResponse EnduserDetail
(System.IAsyncResult result) {
object[] _args =
new object[ 0 ];
Test.ServiceReference1.
userDetailResponse _result =
((Test.ServiceReference1.
userDetailResponse)( base .EndInvoke
( "userDetail" , _args, result)));
return _result;
}

Someone pls help me. thanks.