using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
namespace AAAA
{
///
1<summary>
2/// WebForm1 的摘要说明。
3/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid DataGrid1;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
WebReference.ServiceOracle DBS = new AAAA.WebReference.ServiceOracle();
string sqlstr = "SELECT * FROM "DB"."TABLE" ORAID <> 1";
DataSet DS = DBS.SelectOracle(sqlstr,"TABLE");
DataGrid1.DataSource = DS.Tables["TABLE"].DefaultView;
DataGrid1.DataBind();
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
///
1<summary>
2/// 设计器支持所需的方法 - 不要使用代码编辑器修改
3/// 此方法的内容。
4/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
说明:以上是我用VC.NET开发工具创建了一个ASP.NET下的AAAA解决方案中WebForm1.aspx的cs代码,在WebForm1窗体上放置了一个DataGrid1控件,在该项目中我做了Web引用,其中WebReference是我引用的WebServices,名称是ServiceOracle,SelectOracle是方法,后台数据库是Oracle9i。调试运行时提示我未提供任何数据源,为此郁闷了一个月,至今泪水涟涟...。。。ooo000
没办法,系统提示我最多只能散100分。
---------------------------------------------------------------
>>>运行时提示我未提供任何数据源
is that the error message on the web service side? how did you connect to the database? did you check if there are any records coming back?
DataSet DS = DBS.SelectOracle(sqlstr,"TABLE");
Response.Write(DS != null);
Response.Write(DS.Tables.Count);
Response.Write(DS.Tables["TABLE"].Rows.Count);
//DataGrid1.DataSource = DS.Tables["TABLE"].DefaultView;
//DataGrid1.DataBind();
---------------------------------------------------------------
应该是你的Web Services 服务端问题。
可以在服务端新建aspx页面,来连数据库,试试看问题?
---------------------------------------------------------------
应该是你Web Services 的问题,检查一下Web Services中的连接数据库的代码,如果是写在配置文件中,检查配置文件中的连接字符串
---------------------------------------------------------------
WebReference.ServiceOracle DBS = new AAAA.WebReference.ServiceOracle();
你这句是不是调用了其它项目的引用?看看你调用的代码有没有问题
---------------------------------------------------------------
你直接在IE输入你的服务地址,测试一下看看有没有返回结果!不就再是不是服务段的问题了
---------------------------------------------------------------
在web services的接口处这里DBS.SelectOracle(sqlstr,"TABLE")要加 as dataset,因为他返回的是xml,但必须是dataset光是return dataset不行!
---------------------------------------------------------------
说说我的一点看法:
“我内容中给出的代码,在win程序中可以找到数据源,并能返回DataSet,但在web方式就返回不了”
1、我觉得你可以在WebService的Web.Config文件中添加下面代码:
1<webservices>
2<protocols>
3<add name="HttpPost"></add>
4<add name="HttpGet"></add>
5</protocols>
6</webservices>
允许使用 HttpPost 和 HttpGet 方法调用 WebService
2、你是否是远程调用WebService,如果是远程的话,你的WebService 应该放在具有 公网固定IP的服务器上
---------------------------------------------------------------
1,要确信IIS开启好用,oracle有自己的httpserver把iis给关了
2,看看vs.net连结oracle是否有问题,他的连结比sql麻烦一些
---------------------------------------------------------------
http://www.netyi.net/in.asp?id=lockllb
这个网站能帮你解决几乎所有的问题!