CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
可用分押宝游戏火热进行中... 专题改版:Java Web 专题
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  .NET技术 >  C#

麻烦帮我看看问题出在哪里?急

楼主renyimei(小气包)2006-06-01 16:53:18 在 .NET技术 / C# 提问

using   System;  
  using   System.Data;  
  using   System.Data.SqlClient;  
  namespace   进销存管理系统  
  {  
  ///   <summary>  
  ///   LinkDataBase   的摘要说明。  
  ///   </summary>  
  public   class   LinkDataBase  
  {        
  private   string   strSQL;  
  //与SQLServer的连接字符串的设置  
  private   string   connectionString="workstation   id=localhost;Integrated   Security=SSPI;database=jxcglxt";  
  //与数据库的连接  
                  private   SqlConnection     myConnection;  
  private   SqlCommandBuilder     myCommandBuilder;  
  private   DataSet   ds=new   DataSet   ();  
  private   SqlDataAdapter   da;  
   
  public   LinkDataBase()  
  {  
   
  }  
                 
  //操作脱机数据库(创建了该类的实例时直接使用)  
  //根据输入的SQL语句检索数据库数据  
  public   DataSet   SelectDataBase(string   tempStrSQL,string   tempTableName)  
  {  
  this.strSQL=tempStrSQL;  
                          this.myConnection=new   SqlConnection   (connectionString);  
  this.myConnection.Open();  
  this.da=new   SqlDataAdapter   (this.strSQL,this.myConnection);  
  this.ds.Clear();  
  this.da.Fill(ds,tempTableName);  
  return   ds;  
  //this.myConnection.Close();  
  }  
   
  //数据库数据更新(传DataSet和DataTable的对象)  
  public   DataSet   UpdateDataBase(DataSet   changedDataSet,string   tableName)  
  {  
  this.myConnection=new   SqlConnection   (connectionString);  
  this.myConnection.Open();  
  this.da=new   SqlDataAdapter   (this.strSQL,myConnection);  
  this.myCommandBuilder=new   SqlCommandBuilder(da);  
  this.da.Update(changedDataSet,tableName);  
  return   changedDataSet;   //返回更新了的数据库表  
  //this.myConnection.Close();  
  }  
                   
  //直接操作数据库(未创建该类的实例时直接使用)  
  //检索数据库数据(传字符串,直接操作数据库)  
  public   DataTable   SelectDataBase(string   tempStrSQL)  
  {  
  this.myConnection   =   new   SqlConnection(connectionString);  
  this.myConnection.Open();  
  DataSet   tempDataSet   =   new   DataSet();  
  this.da   =   new   SqlDataAdapter(tempStrSQL,this.myConnection);  
  this.da.Fill(tempDataSet);  
  return   tempDataSet.Tables[0];  
  //this.myConnection.Close();  
  }  
   
  //数据库数据更新(传字符串,直接操作数据库)  
  public   int   UpdateDataBase(string   tempStrSQL)  
  {  
  this.myConnection   =   new   SqlConnection(connectionString);  
  //使用Command之前一定要先打开连接,后关闭连接,而DataAdapter则会自动打开关闭连接  
  myConnection.Open();  
  SqlCommand   tempSqlCommand   =   new   SqlCommand(tempStrSQL,this.myConnection);  
  int   intNumber   =   tempSqlCommand.ExecuteNonQuery();//返回数据库中影响的行数  
  myConnection.Close();  
  return   intNumber;  
  }  
  }  
  }在this.da.Fill(ds,tempTableName);提示如下的错误,请问是什么原因?  
  未处理的“System.Data.SqlClient.SqlException”类型的异常出现在   system.data.dll   中。  
   
  其他信息:   系统错误。  
  问题点数:10、回复次数:0Top

相关问题

关键词

得分解答快速导航

  • 帖主:renyimei

相关链接

  • CSDN .NET频道
  • .NET类图书
  • C#类图书
  • .NET类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
世纪乐知(北京)网络技术有限公司 版权所有, 京 ICP 证 020026 号
北京创新乐知广告有限公司 提供技术支持
Copyright © 2000-2007, CSDN.NET, All Rights Reserved
GongshangLogo