S
Soul
Hi,
I have a web service method which will connect to a Access database, which
look like below:
[WebMethod(Description="Search database based on provided string.")]
public DataSet Search(string strSearch)
{
try
{
string strConnection = @"Provider=Microsoft.Jet.OleDb.4.0;Data Source="
+ (string)Server.MapPath("../global_res/global_db.mdb");
string sqlStatement = "SELECT * FROM Contact ORDER BY ContactId";
this.oleDbConnection.ConnectionString = strConnection;
this.oleDbCommand.CommandText = sqlStatement;
this.oleDbCommand.Connection = this.oleDbConnection;
this.oleDbDataAdapter.SelectCommand = this.oleDbCommand;
this.oleDbConnection.Open();
this.oleDbDataAdapter.Fill(this.dataSet, "Contact");
this.oleDbConnection.Close();
this.FindStaff(strSearch);
return this.dataSet.Copy();
}
catch (Exception ex)
{
return ??????;
}
}
I am wondering if I put a try-catch statement in this method, how should I
return the error text to the page that request this web service method since
this method suppose to return DataSet but not string?
The aspx. page that request this web service method look something like:
CONTACTService cs = new CONTACTService();
this.dataSet = cs.Search(this.TextBoxString.Text.Trim().ToLower());
Please help.
Thank you.
I have a web service method which will connect to a Access database, which
look like below:
[WebMethod(Description="Search database based on provided string.")]
public DataSet Search(string strSearch)
{
try
{
string strConnection = @"Provider=Microsoft.Jet.OleDb.4.0;Data Source="
+ (string)Server.MapPath("../global_res/global_db.mdb");
string sqlStatement = "SELECT * FROM Contact ORDER BY ContactId";
this.oleDbConnection.ConnectionString = strConnection;
this.oleDbCommand.CommandText = sqlStatement;
this.oleDbCommand.Connection = this.oleDbConnection;
this.oleDbDataAdapter.SelectCommand = this.oleDbCommand;
this.oleDbConnection.Open();
this.oleDbDataAdapter.Fill(this.dataSet, "Contact");
this.oleDbConnection.Close();
this.FindStaff(strSearch);
return this.dataSet.Copy();
}
catch (Exception ex)
{
return ??????;
}
}
I am wondering if I put a try-catch statement in this method, how should I
return the error text to the page that request this web service method since
this method suppose to return DataSet but not string?
The aspx. page that request this web service method look something like:
CONTACTService cs = new CONTACTService();
this.dataSet = cs.Search(this.TextBoxString.Text.Trim().ToLower());
Please help.
Thank you.