日期:2014-05-18  浏览次数:20484 次

急问recordset的open方法中,sql语句查询问题!
在recordset的open方法中,写sql查询语句:从两个表联合选出一些属性值。

报错是这一句:objRS.Open(sqlstr, objConn, ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum .adLockBatchOptimistic, 0);
消息:
用户代码未处理 System.Runtime.InteropServices.COMException
  Message="无法绑定由多个部分组成的标识符 \"教师基本信息.工资号\"。"
  Source="Microsoft OLE DB Provider for SQL Server"
  ErrorCode=-2147217900
  StackTrace:
  在 ADODB.RecordsetClass.Open(Object Source, Object ActiveConnection, CursorTypeEnum CursorType, LockTypeEnum LockType, Int32 Options)
  在 简表2.Automation_ADORecordset() 位置 c:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\WebSites\网上申报系统\简表2.aspx.cs:行号 153
  在 简表2.Button1_Click1(Object sender, EventArgs e) 位置 c:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\WebSites\网上申报系统\简表2.aspx.cs:行号 61
  在 System.Web.UI.WebControls.Button.OnClick(EventArgs e)
  在 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
  在 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
  在 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
  在 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
  在 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)


这是部分源码,请各位高手帮忙啊!
ADODB.Connection objConn = new ADODB.Connection();
  ADODB._Recordset objRS = new ADODB.Recordset();
  objConn.Open("Provider=SQLOLEDB;Initial Catalog=网上申报系统;Data Source=COMPUTER\\SQLEXPRESS;uid=sa;pwd=123", "", "", 0);
  objConn.CursorLocation = ADODB.CursorLocationEnum.adUseClient;
  ////object objRecAff;
  ////objRS = (ADODB._Recordset)objConn.Execute("select * from 教师基本信息", out objRecAff,
  //// (int)ADODB.CommandTypeEnum.adCmdTable);

  string sqlstr = "select 职称系列,晋升类型,所在学院,教师基本信息.姓名,教师基本信息.工资号" +
  "from 教师基本信息,资格申请表 where 教师基本信息.工资号 = 资格申请表.工资号 ";

  objRS.Open(sqlstr, objConn, ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum .adLockBatchOptimistic, 0);

------解决方案--------------------
第一,你应该把所有中文的名称都改成英文的

第二,
SQL code
  string sqlstr = "select 职称系列,晋升类型,所在学院,教师基本信息.姓名,教师基本信息.工资号" + 
        "from 教师基本信息,资格申请表 where 教师基本信息.工资号 = 资格申请表.工资号 ";
我的异常网推荐解决方案:软件开发者薪资,http://www.aiyiweb.com/other/1391128.html