C#的,就是一个sql查询语句,返回是dataset
[WebMethod]
public DataSet GetData()
{
string connstr=null,sqlstr=null;
connstr = System.Configuration.ConfigurationSettings.AppSettings["connectionstring"];
System.Data.SqlClient.SqlConnection sqlcnx = new System.Data.SqlClient.SqlConnection(connstr);
sqlcnx.Open();
sqlstr="select * from table1";
try
{
DataSet ds=new DataSet();
//最好要做SQL语句的检查
SqlDataAdapter da=new SqlDataAdapter(sqlstr,sqlcnx);
da.Fill(ds);
return ds;
}
catch
{
return null;
}
finally
{
if( sqlcnx.State == ConnectionState.Open)
{
sqlcnx.Close();
}
}
}