473,322 Members | 1,314 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Connecting to SQL Server using SQL Server Authenitcation

6
hi. I am creating a database using ms access as front end and MS SQL as my back end. I've already created an odbc and was able to access it. The problem is, every time MS Access is restarted, I have to enter the username and password first before I can connect to the server. Is there any way in which I can put this in code? the error says:

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

Thanks a lot in advance.
Aug 10 '07 #1
3 4041
hi. I am creating a database using ms access as front end and MS SQL as my back end. I've already created an odbc and was able to access it. The problem is, every time MS Access is restarted, I have to enter the username and password first before I can connect to the server. Is there any way in which I can put this in code? the error says:

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

Thanks a lot in advance.
whats the code for the connection string? I would recommend using ado:

Expand|Select|Wrap|Line Numbers
  1. Dim rmcn As ADODB.Connection, rmrs As ADODB.Recordset
  2.  
  3. ' Create connection and open connection - remote
  4. Set rmcn = New ADODB.Connection
  5.  
  6. With rmcn
  7.     .Provider = "Microsoft.Access.OLEDB.10.0"
  8.     .Properties("Data Provider").Value = "SQLOLEDB"
  9.     .Properties("Data Source").Value = "servername"
  10.     .Properties("User ID").Value = "User"
  11.     .Properties("Password").Value = "pass"
  12.     .Open
  13. End With
  14.  
  15. ' Open recordset and run sql
  16. Set rmrs = New ADODB.Recordset
  17.  
  18. sql = "query"
  19.  
  20. With rmrs
  21.     Set .ActiveConnection = rmcn
  22.     .Source = sql
  23.     .LockType = adLockOptimistic
  24.     .CursorType = adOpenKeyset
  25.     .Open
  26.  
  27. End With
  28.  
Aug 10 '07 #2
jutz
6
whats the code for the connection string? I would recommend using ado:

Expand|Select|Wrap|Line Numbers
  1. Dim rmcn As ADODB.Connection, rmrs As ADODB.Recordset
  2.  
  3. ' Create connection and open connection - remote
  4. Set rmcn = New ADODB.Connection
  5.  
  6. With rmcn
  7.     .Provider = "Microsoft.Access.OLEDB.10.0"
  8.     .Properties("Data Provider").Value = "SQLOLEDB"
  9.     .Properties("Data Source").Value = "servername"
  10.     .Properties("User ID").Value = "User"
  11.     .Properties("Password").Value = "pass"
  12.     .Open
  13. End With
  14.  
  15. ' Open recordset and run sql
  16. Set rmrs = New ADODB.Recordset
  17.  
  18. sql = "query"
  19.  
  20. With rmrs
  21.     Set .ActiveConnection = rmcn
  22.     .Source = sql
  23.     .LockType = adLockOptimistic
  24.     .CursorType = adOpenKeyset
  25.     .Open
  26.  
  27. End With
  28.  
Thanks lot. :)
That would do for now.
Thanks again :)
Aug 13 '07 #3
if you have the SQLNative drivers installed on all computers, use:

.Properties("Data Provider").Value = "SQLNCLI"

MUCH QUICKER!
Aug 13 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Google Mike | last post by:
After a lot of thought and research, and playing with FreeTDS and InlineTDS, as well as various ODBC connections, I have determined that the fastest and cheapest way to get up and going with PHP on...
1
by: Russell Kahler | last post by:
I have two server defined (S1 and S2) S1 has a link defined to S2. If I open Query Analyzer and run a query referencing S2 server. My statement returns data (lets say I am using MSSQL standard...
4
by: John Morgan | last post by:
I have Enterprise Manager on my local machine. For the last twelve months it has been connecting without problem to my online SQL Server database provided by my ISP. Three weeks ago the ISP...
4
by: CodeImp | last post by:
A simple app I quickly wrote to try getting info from a database. Here is the first part of its code. The rest of the code is irellevant. using System; using System.Data; using...
12
by: Ann Marinas | last post by:
Hi all, I would like to ask for some help regarding separating the asp.net webserver and the sql server. I have created an asp.net application for a certain company. Initially, we installed...
7
by: Alice Wong | last post by:
I am setting up my Web ASP.net application to connect to Sql server using windows authentication. I set up IIS to have integrated windows authenication and sql to allow Windows authentication....
1
by: abc | last post by:
Our web project is used VS2003 and Crystal Reports for Visual Studio.NET. There have reports that directly call to sql server's stored procedure. I also call SetDatabaseLogon method to change user...
3
by: Vinod R.Shenoy | last post by:
Hi All, Came across a post wherin you had helped somebody with a similar problem and was wondering if you could help us out with it. Our problem is , We have a development SQL Server 2000...
2
by: orandov | last post by:
Hi, I am having a problem connecting my .net applications from the application server to the database server. When I run the application from my windows xp (sp2) box it works fine. When I try to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.