关于ASP.NET连接SQL server2000 的问题?
日期:2007-08-14 荐:
关于ASP.NET连接SQL server2000 的问题?原码:<%@ import Namespace="System.Data" %><%@ import Namespace="System.Data.SqlClient" %><%@ Page Language="VB" Debug="true" %><script runat="server">8 Sub Page_Load(Sender As Object,e As EventArgs)9 dim myConnectionString As String10 myConnectionString = "Initial Catalog=NORTHWND;Data Source=localhost;Integrated Security=SSPI;" 11 Dim myConnection As New SqlConnection(myConnectionString) 12 Dim myInsertQuery As String = "INSERT INTO Customers (CustomerID, CompanyName) Values('NWIND', 'Northwind Traders')" 13 Dim myCommand As New SqlCommand(myInsertQuery) 14 myCommand.Connection = myConnection 16 myConnection.Open() 18 myCommand.ExecuteNonQuery() 19 myCommand.Connection.Close() End Sub错误提示:SQL Server 不存在或访问被拒绝。 说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Data.SqlClient.SqlException: SQL Server 不存在或访问被拒绝。源错误: 行 14: myCommand.Connection = myConnection行 15: 行 16: myConnection.Open()行 17: 行 18: myCommand.ExecuteNonQuery() 源文件: D:\asp.net程序\ch7-1.aspx 行: 16 请问,上面有什么问题,能说明一下最好,在线等NORTHWND.MDF是我从sql server上复制的一个数据库或给一个简单的连接sql server 2000的例子 用户名和密码呢"server=localhost;database=pubs;uid=sa;pwd="sql要调成sqlserver和windows混合验证这是我的一个例子%@ import namespace="system.data"%><%@ import namespace="system.data.sqlclient"%><script language="vb" runat="server"> sub page_load(sender as object, e as eventargs) dim objconn as new sqlconnection() objconn.connectionstring= "data source=localhost;integrated security=sspi;" & _ "initial catalog=Friend;" objconn.open() dim sqlstr as string="select 姓名 from 择友俱乐部" dim objcmd as new sqlcommand(sqlstr,objconn) objcmd.executenonquery() objconn.close() end sub</script>wq2000(60-80) 说的对。还有一点,把ASP.NET用户加入SQLSEVER用户里
标签: