This method completes the simple call encapsulation of a simple WebService, implements the unified operation of simple Webservice calls, and avoids the embarrassment of adding an interface method for every additional operation!
/// <summary> /// Encapsulate the same interface call method /// </summary> /// <param name="_strSql">Simple sql passed in</param> /// <param name="_strConnNmae">Connect database string</param> /// <returns>Returned dataset</returns> [WebMethod] public DataSet GeneralDataSet(string _strSql, string _strConnNmae) { DataSet dsResult = null; //Connect the HIS database string ConnectionStringSettings css = new ConnectionStringSettings(); css = [_strConnNmae]; using (OleDbConnection conn = new OleDbConnection()) { (); OleDbCommand cmd = (); using (OleDbDataAdapter ada = new OleDbDataAdapter()) { try { = _strSql; = cmdHIS; (dsResult); } catch (Exception ex) { } } } return dsResult; }
<configuration> <appSettings> <add key="EmrSoapRole" value="/EMR"/> </appSettings> <connectionStrings> <add name="HISConnectionString" connectionString="Data Source=DLFY;Persist Security Info=True;Password=medrec;User ID=medrec" providerName=""/>
//Call ExampleDataSet ds = GeneralDataSet("select * from emp","HisConnectionString");
The above is the entire content of this article, I hope you like it.