WebService simple encapsulation interface call Method
This article mainly introduces WebService's simple encapsulation interface calling method. It is very simple and practical to query the database through simple SQL statements and return dataset. If you need it, you can refer to it.
This method encapsulates simple WebService calls and implements unified operations for simple Webservice calls, avoiding the need to add an interface method for each added operation!
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
/// <Summary> /// Encapsulate the same interface call Method /// </Summary> /// <Param name = "_ strSql"> input simple SQL </param> /// <Param name = "_ strConnNmae"> Connection database string </param> /// <Returns> returned dataset </returns> [WebMethod] Public DataSet GeneralDataSet (string _ strSql, string _ strConnNmae) { DataSet dsResult = null; // Connect to HIS database string ConnectionStringSettings css = new ConnectionStringSettings (); Css = ConfigurationManager. ConnectionStrings [_ strConnNmae]; Using (OleDbConnection conn = new OleDbConnection (css. ConnectionString )) { Conn. Open (); OleDbCommand cmd = conn. CreateCommand (); Using (OleDbDataAdapter ada = new OleDbDataAdapter ()) { Try { CmdHIS. CommandText = _ strSql; Ada. SelectCommand = cmdHIS; Ada. Fill (dsResult ); } Catch (Exception ex) { } } } Return dsResult; } |
?
1 2 3 4 5 6 7 |
<Configuration> <Deleetask> <Add key = "EmrSoapRole" value = "http://www.goodwill.com/EMR"/> </AppSettings> <ConnectionStrings> <Add name = "HISConnectionString" connectionString = "Data Source = DLFY; Persist Security Info = True; Password = medrec; User ID = medrec" providerName = "System. data. oracleClient "/> |
?
1 2 |
// Call example DataSet ds = GeneralDataSet ("select * from emp", "HisConnectionString "); |
The above is all the content of this article. I hope you will like it.