[Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection.

Hello All,

I'm Getting the following error when calling a dll from my vb.net application.
[Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection.
The dll was written in vb6 and accesses a sql db using the following connection string.
Public Const GLOBAL_DNS As String = "DSN=TransSrvFinal;UID=sa;PWD=admin;"
This DLL works fine when called from other Windows Apps. However I'm now trying to call this dll from with in an asp.net application. I'm using vb.net as the codebehind.
I'm assuming I need to somehow setup vb to gain access to the sql server but I'm not sure how to go about doing this. Can someone please help me? Also, why doesn't this work this way?
Thanks in advance.

Tim Thomas
-1
tthomasol
3/1/2004 2:57:40 AM
📁 asp.net.visual-basic.net
📃 3721 articles.
⭐ 0 followers.

💬 7 Replies
👁️‍🗨️ 2517 Views


Try making a more accurate connection string

Open notepad
Make a new text file
Hit save as
Change save as type to "All Files"
save it as whatever.udl
rem. where you saved it and open it in explorer and setup your connection details, test it there.
Reopen the file in notepad
Delete the "Provider=SQLOLEDB.1;" part of the connection string
Use this in your app as the connection string...
Should work, long as it did in the wizard ;).
BTW if your using MS SQL Server why are you using the ODBC connecter? use the built in SQL Connecters they are up to 70% faster than the ODBC varient.

Infinity Squared Technologies 

The Infinite Idea Company (TM)

http://www.thinkist.net



*NOTE* My views express the views of me and not Infinity Squared Technologies...
-1
frazell
3/1/2004 3:57:59 PM
Thanks for the response Frazell!

I got over the connection issue and I also implemented the MS SQL connection instead of ODBC. What a difference! Thanks so much for your advice!
My latest problem is that the dll being called by my VB/ASP.NET app makes use of another dll that is stored on a mapped drive. Now I'm getting the following error when the dll attempts to call it's counterpart.
System.IO.FileNotFoundException: File not found: t:\ShareDLL\Special.dll
The file is there and the dll I'm using to invoke this call works when I call it from other Windows Apps. Do you have any advice?

Tim Thomas
1
tthomasol
3/3/2004 5:54:33 PM
ASP.NET operates in a "least privilaged" account which dosent allow your application (you can modify this but unless its dead needed i dont recommend it) to operate with many permissions, acessing the network is one of those not allowed. I recommend you copy the .dll into the applications bin folder or set VS to do that for you.

This greatly reduces your attack surface if your server is comprimised thru your application.

Infinity Squared Technologies 

The Infinite Idea Company (TM)

http://www.thinkist.net



*NOTE* My views express the views of me and not Infinity Squared Technologies...
1
frazell
3/3/2004 7:15:38 PM
Thanks again for your response Frazell,

I followed your instructions and loaded the dll in question locally. This took care of my problem and I can continue to develope my project. However when we go live with this I will need to be using the shared location for this dll because of licensing restrictions on the dll in question. Is there some way for me to give my .net application access to our shared T drive?
Thanks,
Tim

Tim Thomas
0
tthomasol
3/4/2004 4:55:34 PM
This document will explain how to change process identity for your ASP.NET app. But as i warned earlier really try to take security into mind.

http://docs.aspng.com/quickstart/aspplus/doc/procmodel.aspx

Infinity Squared Technologies 

The Infinite Idea Company (TM)

http://www.thinkist.net



*NOTE* My views express the views of me and not Infinity Squared Technologies...
0
frazell
3/5/2004 2:02:12 PM
Thanks for all your help Frazell!

Tim Thomas
0
tthomasol
3/5/2004 4:52:48 PM
Never a problem ;)

Infinity Squared Technologies 

The Infinite Idea Company (TM)

http://www.thinkist.net



*NOTE* My views express the views of me and not Infinity Squared Technologies...
0
frazell
3/5/2004 6:04:04 PM
Reply: