|
-
Mar 31st, 2005, 03:55 AM
#1
Thread Starter
Addicted Member
help needed establishing connection with sql-server
i have an asp.net application running on "aspnetserver" (win2000 adv server) under the profile "artscar" which is a local administratoraccount on "aspnetserver".
My sql database i'd like to connect to is on "sqlserver".
I have a working system DSN on "aspnetserver" pointing to the correct database on "sqlserver"
i try to connect with:
Code:
dim con as odbcconnection
dim cmd as odbccommand
dim constring as string = "DSN=MYDSN"
con = new Microsoft.Data.Odbc.Odbcconnection(constring)
con.open
cmd = new odbccommand("select......................", con) <------error occurs here
i get error 28000 :Login failed for user '(null)'.Reason:Not Associated with a trusted SQL Server connection.
i tried adding iusr_aspnetserver to the users on "sqlserver" and in sqlserver itself. iis is set up for anonymous access + integrated windows identification...
The debugging crashes at con.open, and i'm really lost at what to look for
never argue with an idiot, he will bring you down to his level and will beat you through experience
-
Mar 31st, 2005, 04:07 AM
#2
Re: help needed establishing connection with sql-server
Do you have to use a system DSN?
-
Mar 31st, 2005, 04:12 AM
#3
Thread Starter
Addicted Member
Re: help needed establishing connection with sql-server
that's what i am using... but only because i couldn't connect through sqlconnection...
I doesn't really matter how i connect, i'm willing to try everything!
never argue with an idiot, he will bring you down to his level and will beat you through experience
-
Mar 31st, 2005, 04:38 AM
#4
Re: help needed establishing connection with sql-server
First, Import System.Data.SqlClient
VB Code:
Dim sqlConn As New SqlConnection(connectionString)
sqlConn.Open()
Where connectionstring would be:
VB Code:
connectionString = "Data Source=SERVERNAME;Initial Catalog=DATABASENAME;User Id=some_login;Password=some_password;"
In Enterprise Manager, ensure that you're using SQL Server authentication and that some_login is created.
-
Mar 31st, 2005, 04:41 AM
#5
Re: help needed establishing connection with sql-server
To retrieve the data in a dataset,
VB Code:
Dim strSQL As String = "SELECT * FROM tablename"
Dim mySqlDataAdapter As SqlDataAdapter = New SqlDataAdapter(strSQL, sqlConn)
mySqlDataAdapter.Fill(ds)
-
Mar 31st, 2005, 04:41 AM
#6
Thread Starter
Addicted Member
Re: help needed establishing connection with sql-server
I'm trying it immediatly!
i was reviewing (http://www.connectionstrings.com/), i'm trying hard
never argue with an idiot, he will bring you down to his level and will beat you through experience
-
Mar 31st, 2005, 05:01 AM
#7
Thread Starter
Addicted Member
Re: help needed establishing connection with sql-server
Code:
Imports System.Data.SqlClient
Public Class WebForm1
Inherits System.Web.UI.Page
Protected WithEvents DropDownList1 As System.Web.UI.WebControls.DropDownList
Protected WithEvents btnMessagebox As System.Web.UI.WebControls.Button
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'sqlconnection
Dim CON As New SqlConnection()
Dim CMD As SqlCommand
Dim DTR As SqlDataReader
'standard security
CON.ConnectionString = "Data Source=ZON;Initial Catalog=ElecFys;User Id=artscar;Password=*********"
CON.Open()
End Sub
How can i ensure that im using sql server authentification? I tried doing it by >tools>SQL server configuration properties>security. If i click the radiobutton "SQL server and windows", hit ok and then check again: it is still at "windows only". Maybe because this server is allready in use to serve some existing vb-applications?
In the section users(in sqlserver on ZON) under ElecFys(dbname) i added the user "ZON\artscar".
the error :System.Data.SqlClient.SqlException: Login failed for user 'artscar'. Reason: Not associated with a trusted SQL Server connection.
never argue with an idiot, he will bring you down to his level and will beat you through experience
-
Mar 31st, 2005, 05:16 AM
#8
Re: help needed establishing connection with sql-server
From www.connectionstrings.com, try this string as well:
"Server=Aron1;Database=pubs;User ID=sa;Password=asdasd;Trusted_Connection=False"
Also, when you switched to sql server authentication, did you restart sql server?
-
Mar 31st, 2005, 05:26 AM
#9
Thread Starter
Addicted Member
Re: help needed establishing connection with sql-server
no, i couldn't do that, the database was in use by other users as well...
but now that everyone is one lunchbreak i can restart. Will this change anything for the existing visual basic applications?
never argue with an idiot, he will bring you down to his level and will beat you through experience
-
Mar 31st, 2005, 05:32 AM
#10
Re: help needed establishing connection with sql-server
Yes it will. If other apps use it, you can specify to use SQL Server authentication for that particular database.
-
Mar 31st, 2005, 06:03 AM
#11
Thread Starter
Addicted Member
Re: help needed establishing connection with sql-server
how can i do this? i can't seem to do it for just one database...
never argue with an idiot, he will bring you down to his level and will beat you through experience
-
Mar 31st, 2005, 06:46 AM
#12
Thread Starter
Addicted Member
Re: help needed establishing connection with sql-server
Code:
Imports System.Data.SqlClient
Public Class WebForm1
Inherits System.Web.UI.Page
Protected WithEvents DropDownList1 As System.Web.UI.WebControls.DropDownList
Protected WithEvents btnMessagebox As System.Web.UI.WebControls.Button
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'sqlconnection
Dim CON As New SqlConnection()
Dim CMD As SqlCommand
Dim DTR As SqlDataReader
'standard security
CON.ConnectionString = "Data Source=ZON;Initial Catalog=ElecFys;User Id=artscar;Password=*********"
CON.Open()
End Sub
nothing works...
while i am in visual studio.net i have no problem browsing the tables in the sqldatabase. can't i use the account visual studio uses?
never argue with an idiot, he will bring you down to his level and will beat you through experience
-
Mar 31st, 2005, 07:00 AM
#13
Thread Starter
Addicted Member
Re: help needed establishing connection with sql-server
never argue with an idiot, he will bring you down to his level and will beat you through experience
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|