using System.Collections;
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Web;
using System.Web.Services;
using System.Data.SqlClient;
namespace GetFlightInfo
{
///
/// Service1 的摘要说明。
///
public class GFlightInfo : System.Web.Services.WebService
{
private System.Data.SqlClient.SqlDataAdapter sqlAdapter;
public GFlightInfo()
{
//CODEGEN: 该调用是 ASP.NET Web 服务设计器所必需的
InitializeComponent();
SqlCommandBuilder builder;
string sql="select * from Tab_Flight";
string connstr="user id =sa;password=;database=Tab_Flight;server=localhost";
sqlAdapter=new SqlDataAdapter(sql,connstr);
builder=new SqlCommandBuilder(sqlAdapter);
}
#region 组件设计器生成的代码
//Web 服务设计器所必需的
private IContainer components = null;
///
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
///
private void InitializeComponent()
{
}
///
/// 清理所有正在使用的资源。
///
protected override void Dispose( bool disposing )
{
if(disposing && components != null)
{
components.Dispose();
}
base.Dispose(disposing);
}
#endregion
// WEB 服务示例
// HelloWorld() 示例服务返回字符串 Hello World
// 若要生成,请取消注释下列行,然后保存并生成项目
// 若要测试此 Web 服务,请按 F5 键
[WebMethod]
public DataSet GetFlightInfo()
{
DataSet ds=new DataSet();
sqlAdapter.Fill(ds,"Tab_Flight"
;
return ds;
}
}
}
这是我自己做的,可编译后返回的结果却是:
System.Data.SqlClient.SqlException: SQL Server 不存在或访问被拒绝。
at System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction)
at System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction)
at System.Data.SqlClient.SqlConnection.Open()
at System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState& originalState)
at System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable)
at GetFlightInfo.GFlightInfo.GetFlightInfo() in c:\inetpub\wwwroot\getflightinfo\service1.asmx.cs:line 69
大虾们,能否指明一下哪里有问题了?
|