.Net 2005 添加控件的问题

来源:百度知道 编辑:UC知道 时间:2024/05/29 20:12:35
我是个新手,我想问一下,我在工具栏中添加了SqlConnection SqlDataAdapter两个控件,可是为什么是灰色的不可用呢?为啥呢?请各位帮一下忙啊,能说的详细一点么?那要是手写的话,connection 里的连接字符串应该怎么写啊?就是 uid pwd database阿什么的。
我试了一下 ,出现的错误是:拒绝了对对象 'UserInfo'(数据库 'pubs',所有者 'dbo')的 SELECT 权限。
这到底是怎么回事儿啊?服了……

string connectionString = "Data Source=127.0.0.1;Initial Catalog=northwind;Integrated Security=false;User ID=sa;password=123456";
SqlConnection sqlcon = new SqlConnection(connectionString);

或者你用2005里面的连接到数据库,之后连接字符串就会保存在web.config里面,然后你就可以直接调用了

补充:出现这个问题,应该是你对这个userinfo表没有select权限吧

SqlConnection sqlcon = new SqlConnection("server=(local)或IP;database=数据库名;uid=sa;pwd=sa");