代码如下:
<%@ Import Namespace="System.Data"%>
<%@ Import Namespace="System.Data.SqlClient"%>
<script language="c#" runat="server">
void Page_Load()
{
SqlConnection thisConnection=new SqlConnection(@"Data Source=(local);Integrated Security=SSPI;Initial Catalog=northwind");
thisConnection.Open();
SqlDataAdapter thisAdapter=new SqlDataAdapter("select CustomerID,CompanyName from Customers",thisConnection);
SqlCommandBuilder thisBuilder=new SqlCommandBuilder(thisAdapter);
DataSet thisDataSet=new DataSet();
thisAdapter.Fill(thisDataSet,"Customers");
DataGrid1.DataSource=thisDataSet.Tables["Customers"].DefaultView;
DataGrid1.DataBind();
}
</script>
<html>
<head>
<title Data Grid Control example</title>
</head>
<body>
<asp:DataGrid id="DataGrid1" runat="server"/>
</body>
</html>运行后一直提示登陆失败,好郁闷。不知道哪里出问题了。大侠们快来帮帮小弟啊
<%@ Import Namespace="System.Data"%>
<%@ Import Namespace="System.Data.SqlClient"%>
<script language="c#" runat="server">
void Page_Load()
{
SqlConnection thisConnection=new SqlConnection(@"Data Source=(local);Integrated Security=SSPI;Initial Catalog=northwind");
thisConnection.Open();
SqlDataAdapter thisAdapter=new SqlDataAdapter("select CustomerID,CompanyName from Customers",thisConnection);
SqlCommandBuilder thisBuilder=new SqlCommandBuilder(thisAdapter);
DataSet thisDataSet=new DataSet();
thisAdapter.Fill(thisDataSet,"Customers");
DataGrid1.DataSource=thisDataSet.Tables["Customers"].DefaultView;
DataGrid1.DataBind();
}
</script>
<html>
<head>
<title Data Grid Control example</title>
</head>
<body>
<asp:DataGrid id="DataGrid1" runat="server"/>
</body>
</html>运行后一直提示登陆失败,好郁闷。不知道哪里出问题了。大侠们快来帮帮小弟啊
解决方案 »
- C#中timer控件定时触发button事件
- 如何把listbox中的每个字符串都快速的加到一个hashset中
- 文件读取xml配置文件报错
- 如何在vs2005中添加MicrosoftExcel11.0 Object Library引用
- 请问为啥我的键盘没有反应?
- C#如何调用C++开发的dll中的函数
- 企业库怎么把连接串写死到代码里面,不想放在config文件里面
- 现实自动发送短信--在线等?
- C#中如何将一个类用XML序列化后,作为一个节点添加到已存在的xml文件中
- ******求大神,怎么吧word里面表格的数据 添加到数据库里面*******
- 转换到vs2005,hashtable出现了问题
- 如何匹配空串或任意数字组成的字符串
这个不对吧.
上面这步可以省略吧连接字符串中的sa pwd?
1 在SqlServer上执行下列语句
sp_grantlogin '你的计算机名\ASPNET'
GO
sp_grantdbaccess '你的计算机名\ASPNET', 'myuser'
GO
sp_addrolemember 'db_owner', 'myuser'
GO2.将Integrated Security=SSPI删除,改为SqlServer 用户名和密码
这个的格式是怎么写的,麻烦高手再说一下了.是:SqlServer=我的用户名&我的密码 这样写吗.谢谢
oSQLConn.ConnectionString="Driver={SQL Server};Server=computer or ip;Database=pubs;Uid=sa;Pwd=asdasd;"
oSQLConn.Open();
oSQLConn.ConnectionString="Driver={SQL Server};Server=计算机名或IP;Database=数据库名;Uid=用户名;Pwd=密码;"
oSQLConn.Open();
User ID=sa;Pwd=sa账号的密码
Data Source=localhost
SqlConnection thisConnection=new SqlConnection(@"Data Source=(local);Integrated Security=SSPI;Initial Catalog=northwind");看看这个你就明白怎么建立连接了
http://www.connectionstrings.com/
Data Source=(local) 这个不对吧,应该是
Data Source=localhost(local)是对的,localhost在XP下不能用,2000上可以。你代码的其它地方没看出有什么错误,你再检查一下其它地方。
和Server=127.0.0.1试试.