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

错误描述:
Error 1 The type or namespace name 'SqlConnection' could not be found (are you missing a using directive or an assembly reference?) E:\周金玉\net\person_web\Default.aspx.cs 27 10 E:\...\person_web\

Error 2 The type or namespace name 'SqlConnection' could not be found (are you missing a using directive or an assembly reference?) E:\周金玉\net\person_web\Default.aspx.cs 27 41 E:\...\person_web\

Error 3 The type or namespace name 'SqlCommand' could not be found (are you missing a using directive or an assembly reference?) E:\周金玉\net\person_web\Default.aspx.cs 30 9 E:\...\person_web\

Error 4 The type or namespace name 'SqlCommand' could not be found (are you missing a using directive or an assembly reference?) E:\周金玉\net\person_web\Default.aspx.cs 30 34 E:\...\person_web\

Error 5 The type or namespace name 'SqlParameter' could not be found (are you missing a using directive or an assembly reference?) E:\周金玉\net\person_web\Default.aspx.cs 31 36 E:\...\person_web\

Error 6 The type or namespace name 'SqlParameter' could not be found (are you missing a using directive or an assembly reference?) E:\周金玉\net\person_web\Default.aspx.cs 32 36 E:\...\person_web\

这是我的原代码:

protected void Button2_Click(object sender, EventArgs e)
{
String caption = TextBox2.Text;
bool ispublic = false;
if (CheckBox1.Checked)
ispublic = true;
addalbum(caption, ispublic);
}
public static void addalbum(string caption, bool ispublic)
{
SqlConnection connection = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["personal"].ToString());
string sql;
sql = "insert into albums([caption],[ispublic])values(@caption,@ispublic)";
SqlCommand command = new SqlCommand(sql, connection);
command.parameters.add(new SqlParameter("@caption",caption));
command.parameters.add(new SqlParameter("@ispublic",ispublic));
connection.open();
command.executenonquery();
}
请会的指教在下!谢谢了!我刚学!

搜索更多相关主题的帖子: 数据库 
2006-09-26 15:54
niuyanfang
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2006-9-1
收藏
得分:0 

先看看你的关键字的大小写,好像有些不准确!时间太紧,明天来了再看看!我也是刚刚入门,一起学习一下

2006-09-26 18:04
kdjinyu
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2006-1-14
收藏
得分:0 
是啊,我也知道大小写问题,可改了半天还是那样子~!快疯了都.

2006-09-27 08:57
小海龟
Rank: 6Rank: 6
等 级:贵宾
威 望:23
帖 子:1068
专家分:4
注 册:2006-8-1
收藏
得分:0 
String 改成:string
open() 改成:Open()
executenonquery()改成:ExecuteNonQuery()
晕,都是大小写的问题.

[bc09] 犯强汉者,虽远比诛!
2006-09-27 12:13
小海龟
Rank: 6Rank: 6
等 级:贵宾
威 望:23
帖 子:1068
专家分:4
注 册:2006-8-1
收藏
得分:0 
还有我没改完的.

[bc09] 犯强汉者,虽远比诛!
2006-09-27 12:13
kdjinyu
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2006-1-14
收藏
得分:0 
谢谢老兄了,我试试.以前用的是asp,现在用这个,大小写就老出问题.呵呵,多谢!

2006-09-28 18:01
hoya
Rank: 5Rank: 5
等 级:贵宾
威 望:15
帖 子:538
专家分:0
注 册:2006-6-27
收藏
得分:0 

不是有代码提示吗??

不区分大小写就用vb.net吧...


妈的...一天能卖一颗就很不错了...
2006-09-29 17:25
快速回复:[求助]请教数据库连接的错误.
数据加载中...
 
   



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

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