G
Guest
This function works in a Windows Forms .Net application, but when I try it in
an ASP.Net application, I get an error:
Cannot open database "codelib" requested by the login. The login failed.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.
Exception Details: System.Data.OleDb.OleDbException: Cannot open database
"codelib" requested by the login. The login failed.
Function SqlTest() As String
Dim cn As New OleDbConnection
Dim cmd As New OleDbCommand
Dim strConn As String
Dim strSql As String
strConn = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist
Security Info=False;Initial Catalog=codelib;Data
Source=X3934834392\SQLEXPRESS;Use Procedure for Prepare=1;Auto
Translate=True;Packet Size=4096;Workstation ID=X3934834392;Use Encryption for
Data=False;Tag with column collation when possible=False"
cn.ConnectionString = strConn
cn.Open()
strSql = "SELECT tblCode.title FROM tblCode WHERE tblCode.ID=" & 1 &
";"
cmd = New OleDbCommand(strSql, cn)
Return CStr(cmd.ExecuteScalar)
End Function
Does anybody know what I'm doing wrong or not doing?
Thanks.
an ASP.Net application, I get an error:
Cannot open database "codelib" requested by the login. The login failed.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.
Exception Details: System.Data.OleDb.OleDbException: Cannot open database
"codelib" requested by the login. The login failed.
Function SqlTest() As String
Dim cn As New OleDbConnection
Dim cmd As New OleDbCommand
Dim strConn As String
Dim strSql As String
strConn = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist
Security Info=False;Initial Catalog=codelib;Data
Source=X3934834392\SQLEXPRESS;Use Procedure for Prepare=1;Auto
Translate=True;Packet Size=4096;Workstation ID=X3934834392;Use Encryption for
Data=False;Tag with column collation when possible=False"
cn.ConnectionString = strConn
cn.Open()
strSql = "SELECT tblCode.title FROM tblCode WHERE tblCode.ID=" & 1 &
";"
cmd = New OleDbCommand(strSql, cn)
Return CStr(cmd.ExecuteScalar)
End Function
Does anybody know what I'm doing wrong or not doing?
Thanks.