accessing database using webservice
C#
3
Posts
3
Posters
0
Views
1
Watching
-
Hi ronin, You can access the database from the webservice in the same way you access from the other applications. The following lines of code connect to the database and return the results in the form of a dataset. [WebMethod] public DataSet GetData() { SqlConnection conn = new SqlConnection(); string connstring = "Persist Security Info=false; Integrated Security =false; database=DATABASENAME; server=DATABASESERVERNAME; User ID=USERID; Password=PASSWORD"; conn.ConnectionString = connstring; DataSet ds = new DataSet("Employee Data Set"); SqlDataAdapter adptr = new SqlDataAdapter("select * from TABLE NAME", connstring); adptr.Fill(ds); return ds; } Hope this will help you. Regards SGS