当前位置:编程学习 > C#/ASP.NET >>

数据库的连接问题 我感觉没什么问题的 请高手指点下

string  connectionString = ("server=localhost;Integrated  Security=SSPI;database = customer");
SqlConnection  SconnStr = new SqlConnection(connectionString);
SqlCommand cmd = new SqlCommand("select telephoto from customer  where customer==uio",SconnStr);
SqlDataReader  red=null;
SconnStr.Open();
try
{

  red = cmd.ExecuteReader();
}
catch(Exception err)
{
if(err!=null) Console.Write(err.ToString());
}
在try下的red = cmd.ExecuteReader();中断 出现未处理的“System.Data.SqlClient.SqlException”类型的异常出现在 system.data.dll 中。  不知道怎么会事  望高手指点下 --------------------编程问答-------------------- try
{
SqlDataReader red = cmd.ExecuteReader(); --------------------编程问答-------------------- 还是不行啊 --------------------编程问答-------------------- select telephoto from customer  where customer==uio

==>

select telephoto from customer  where customer='uio' --------------------编程问答-------------------- select telephoto from customer  where customer"=="uio --------------------编程问答-------------------- 自己设个断点调试下就可以了. --------------------编程问答-------------------- select telephoto from customer  where customer='uio'
--------------------编程问答-------------------- SqlCommand cmd = new SqlCommand("select telephoto from customer  where customer==uio",SconnStr);//多个=号,customer如果是字符型,uio--》'uio'

--------------------编程问答-------------------- 唉  还是不行 --------------------编程问答-------------------- 可能缺少引用? --------------------编程问答-------------------- 呵呵  搞定  string  connectionString = (@"Data Source =(local);;integrated security=SSPI; Initial Catalog = customer");这样写就可以 也不知道怎么搞的  是不是跟电脑有关系的 --------------------编程问答-------------------- server=你的计算机名,
不要用server=localhost
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,