| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 734 人关注过本帖
标题:[求助]数据库连接的问题
只看楼主 加入收藏
wkm2000
Rank: 1
等 级:新手上路
帖 子:119
专家分:0
注 册:2006-3-6
收藏
 问题点数:0 回复次数:5 
[求助]数据库连接的问题

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace hetongguanlixitong
{
/// <summary>
/// huizong 的摘要说明。
/// </summary>
public class huizong : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button quanbu;
protected System.Web.UI.WebControls.Button zhixing;
protected System.Web.UI.WebControls.Button gongsi;
protected System.Web.UI.WebControls.Button guoqi;
protected System.Web.UI.WebControls.TextBox TextBox;
protected System.Web.UI.WebControls.HyperLink fanhui;
protected System.Web.UI.WebControls.DataGrid MyDataGrid;
protected System.Web.UI.WebControls.Button jinxing;
protected System.Web.UI.WebControls.CheckBoxList MyCheckBoxList;
protected System.Web.UI.WebControls.Button jinxingzhong ;

private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if(! Page.IsPostBack)
{
Bind_Mydatagrid();
}
}

#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.quanbu.Click += new System.EventHandler(this.quanbu_Click);
this.zhixing.Click += new System.EventHandler(this.zhixing_Click);
this.gongsi.Click += new System.EventHandler(this.gongsi_Click);
this.guoqi.Click += new System.EventHandler(this.guoqi_Click);
this.jinxing.Click += new System.EventHandler(this.jinxing_Click);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion


private void quanbu_Click(object sender, System.EventArgs e)
{
SQLConnection myConnection= new SQLConnection("server=localhost; uid=sa; pwd=; database=hetongguanlixitong");
myConnection.open ( );

SQLDataSetCommand myCommand= new SQLDataSetCommand("HeTongQuanBu" , myConnection);
myCommand.CommandType=CommandType.StoredProcedure;


DataSet ds = new DataSet();
MyCommand.FillDataSet(ds, "GongSiBiao, HeTongBiao");

MyDateGrid.DataSource=ds.Tables["GongSiBiao, HeTongBiao"].DefaultView;
MyDataGrid.DataBind();

myConnection.close();
}
他报以下的错误.这是咋回事啊?
d:\inetpub\wwwroot\hetongguanlixitong\huizong.aspx.cs(69): 找不到类型或命名空间名称“SQLConnection”(是否缺少 using 指令或程序集引用?)
d:\inetpub\wwwroot\hetongguanlixitong\huizong.aspx.cs(70): 找不到类型或命名空间名称“myConnection”(是否缺少 using 指令或程序集引用?)
d:\inetpub\wwwroot\hetongguanlixitong\huizong.aspx.cs(72): 找不到类型或命名空间名称“SQLDataSetCommand”(是否缺少 using 指令或程序集引用?)
d:\inetpub\wwwroot\hetongguanlixitong\huizong.aspx.cs(73): 找不到类型或命名空间名称“myCommand”(是否缺少 using 指令或程序集引用?)
d:\inetpub\wwwroot\hetongguanlixitong\huizong.aspx.cs(78): 找不到类型或命名空间名称“MyCommand”(是否缺少 using 指令或程序集引用?)
d:\inetpub\wwwroot\hetongguanlixitong\huizong.aspx.cs(80): 找不到类型或命名空间名称“MyDateGrid”(是否缺少 using 指令或程序集引用?)
d:\inetpub\wwwroot\hetongguanlixitong\huizong.aspx.cs(83): 找不到类型或命名空间名称“myConnection”(是否缺少 using 指令或程序集引用?)

搜索更多相关主题的帖子: using System 数据库 Web summary 
2006-06-20 09:44
daisycutter
Rank: 1
等 级:新手上路
帖 子:30
专家分:0
注 册:2006-2-23
收藏
得分:0 
导入命名空间啊
using System.Data.SqlClient;
2006-06-20 12:57
wkm2000
Rank: 1
等 级:新手上路
帖 子:119
专家分:0
注 册:2006-3-6
收藏
得分:0 
我不是写了吗?!!

MSN:wkm821215@ OICQ:49297869 ^_^
2006-06-20 14:06
wkm2000
Rank: 1
等 级:新手上路
帖 子:119
专家分:0
注 册:2006-3-6
收藏
得分:0 
我现在已经知道是因为大小写的问题了.就是不知道该怎么改.帮忙啊!!!主要是我加粗,下划线的地方.
SqlConnection myConnection= new SqlConnection("server=localhost; uid=sa; pwd=; database=hetongguanlixitong");
myConnection.Open ( );

SQLDataSetCommand myCommand= new SQLDataSetCommand("HeTongQuanBu" , myConnection);
myCommand.CommandType=CommandType.StoredProcedure;


DataSet ds = new DataSet();
MyCommand.FillDataSet(ds, "GongSiBiao, HeTongBiao");

MyDateGrid.DataSource=ds.Tables["GongSiBiao, HeTongBiao"].DefaultView;
MyDataGrid.DataBind();

myConnection.close();

MSN:wkm821215@ OICQ:49297869 ^_^
2006-06-20 17:35
小笨笨
Rank: 5Rank: 5
等 级:贵宾
威 望:19
帖 子:1169
专家分:0
注 册:2006-4-17
收藏
得分:0 

SQLDataSetCommand?这是什么?


上面的给你改了,

SqlConnection myConnection= new SqlConnection("server=localhost; uid=sa; pwd=; database=hetongguanlixitong");
myConnection.Open();

SqlCommand myCommand= new SqlCommand("HeTongQuanBu" , myConnection);
myCommand.CommandType = CommandType.StoredProcedure;


但是
MyCommand.FillDataSet(ds, "GongSiBiao, HeTongBiao");这种用法,我是没见过的。


欢迎光临我的博客: http://smallfools.blog./default.html
2006-06-21 12:16
wkm2000
Rank: 1
等 级:新手上路
帖 子:119
专家分:0
注 册:2006-3-6
收藏
得分:0 
我已经知道是为什么了.我用的资料太老了.现在已经不用sqldatasetcommand了.应该是sqldataadapter
谢谢斑竹提醒啦!

MSN:wkm821215@ OICQ:49297869 ^_^
2006-06-29 16:57
快速回复:[求助]数据库连接的问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.022479 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved