J
jcandamo
I'm new to SQL server programming and trying to open a connection to
MS SQL Server 2005 from VB.NET. I created a new databse called lion;
thus in the browsing file folder window in "MS SQL Server Management
Studio Express" lion appears under "Databases"
and changed the "Databases>security>logins>sa" password to xxx
from vb.net I try to connect but get the following error:
"Login failed for user 'sa'. The user is not associated with a trusted
SQL Server connection."
If I right click on lion and go to properties the server name is DCORE
\SQLEXPRESS
I know is basic, but I'm having problems finding the solution to this
in the previous postings. Any help on this matter would be greatly
appreciated
The complete code is this:
Namespace lion
Public Class DB
'database connect
Private Function connect() As SqlConnection
Dim connectionstring As String
connectionstring = "Initial Catalog=lion;Data Source=DCORE
\SQLEXPRESS;User Id=sa;Password=xxx"
Dim cn As New SqlConnection(connectionstring)
Return cn
End Function
Public Function login(ByVal un As String, ByVal psw As String)
As DataSet
Dim cn As New SqlConnection
Dim sql As String
Dim ds As New DataSet
Dim dtContacts As New DataTable("Customers")
ds = Nothing
sql = "SELECT * FROM Customers'"
'use the connection function created above
cn = connect()
cn.Open()
'can't load connection
If cn.State = 0 Then
Exit Function
End If
Dim da As New SqlDataAdapter(sql, cn)
da.Fill(ds, "Contacts")
'cn.Close() -- note: connection closed automatically by
da.Fill
Return ds
End Function
End Class
End Namespace
MS SQL Server 2005 from VB.NET. I created a new databse called lion;
thus in the browsing file folder window in "MS SQL Server Management
Studio Express" lion appears under "Databases"
and changed the "Databases>security>logins>sa" password to xxx
from vb.net I try to connect but get the following error:
"Login failed for user 'sa'. The user is not associated with a trusted
SQL Server connection."
If I right click on lion and go to properties the server name is DCORE
\SQLEXPRESS
I know is basic, but I'm having problems finding the solution to this
in the previous postings. Any help on this matter would be greatly
appreciated
The complete code is this:
Namespace lion
Public Class DB
'database connect
Private Function connect() As SqlConnection
Dim connectionstring As String
connectionstring = "Initial Catalog=lion;Data Source=DCORE
\SQLEXPRESS;User Id=sa;Password=xxx"
Dim cn As New SqlConnection(connectionstring)
Return cn
End Function
Public Function login(ByVal un As String, ByVal psw As String)
As DataSet
Dim cn As New SqlConnection
Dim sql As String
Dim ds As New DataSet
Dim dtContacts As New DataTable("Customers")
ds = Nothing
sql = "SELECT * FROM Customers'"
'use the connection function created above
cn = connect()
cn.Open()
'can't load connection
If cn.State = 0 Then
Exit Function
End If
Dim da As New SqlDataAdapter(sql, cn)
da.Fill(ds, "Contacts")
'cn.Close() -- note: connection closed automatically by
da.Fill
Return ds
End Function
End Class
End Namespace