未于信任SQL Server连接,大家帮我看看错在那了?谢谢

zkkxy 2008-07-17 01:20:16
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class Default14 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection conn=new SqlConnection();
conn.ConnectionString = "Server=localhost;Database=youbian;UID=sa;Pwd=";
conn.Open();
string strSql="select*from youbian where quhao='quhao.Text'";
SqlCommand MyCommand=new SqlCommand(strSql,conn);
SqlDataReader MyReader=MyCommand.ExecuteReader();
Label2.Text = MyReader.GetString(1);
conn.Close();
}
}
...全文
43 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
hj198777 2008-07-18
  • 打赏
  • 举报
回复
将SQL的认证模式改为 sql与windows混合认证 就OK了
mengjun5200 2008-07-17
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 Leftie 的回复:]
将SQL的认证模式改为 sql与windows混合认证 再试试
[/Quote]
饮水需思源 2008-07-17
  • 打赏
  • 举报
回复
将SQL的认证模式改为 sql与windows混合认证 再试试
je_ck 2008-07-17
  • 打赏
  • 举报
回复
我看是你数据库的连接模式设置错了吧

改为SQL和windows混合模式
JustLovePro 2008-07-17
  • 打赏
  • 举报
回复
不能想当然~
winner2050 2008-07-17
  • 打赏
  • 举报
回复
[Quote=引用楼主 zkkxy 的帖子:]
conn.ConnectionString = "Server=localhost;Database=youbian;UID=sa;Pwd=";
[/Quote]
conn.ConnectionString = "Server=(local);Database=youbian;UID=sa;Pwd=";

这玩意不是web服务器,根本不懂localhost是什么。
zhouwen520 2008-07-17
  • 打赏
  • 举报
回复
孩子你写的是什么代码啊 !写的太笼统了
1,没密码吗????
2, string url = "Server=.;Database=youbian;UID=sa;Pwd=;" SqlConnection conn=new SqlConnection(url);
conn.Open();


61,819

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧