ADO Connection fails with 'sa' 
Author Message
 ADO Connection fails with 'sa'

MVP's-

I have been learning ADO, and I have what I think might
be a simple question.  With an ADP and MSDE, I have put
forth the following code (which I believe works, however
it is telling me that my login to the SQL Server database
fails with 'sa').

[Microsoft][ODBC SQL Server Driver][SQL Server]login
failed for user 'sa'.

When I setup the database, I did not change the login (I
left it as 'sa' with no password).  Is there a reason
that a login would fail with 'sa'?  The ADP file IS
accessing the tables already.

Here is my code:

Private Sub AddParameter_Click()
On Error GoTo Err_AddParameter_Click

Dim conn As adodb.Connection
Dim strInsert As String
Dim intGenericPart As Long

Set conn = ADO_Connect

MsgBox "connection is: " & conn.State

intGenericPart = Forms![frmGenericPartDetail]!
[GenericPartID]

strInsert = "INSERT INTO tblRequirements (GenericPartID,
ParameterID) VALUES (" & intGenericPart & ", " &
Me.ParameterID & ")"

conn.Execute (strInsert)

Exit_AddParameter_Click:
    Exit Sub

Err_AddParameter_Click:
    MsgBox Err.Description
    Resume Exit_AddParameter_Click

End Sub

Here is the function:

Function ADO_Connect() As adodb.Connection

    Dim sConn       As String
    Dim cnConn      As adodb.Connection

    On Error GoTo ErrorHandler

    sConn = "driver={SQL Server}"
    sConn = sConn & ";server=mystation"  'my workstation
and the Server name in the SQL Server Service manager
    sConn = sConn & ";uid=sa"
    sConn = sConn & ";pwd=''"
    sConn = sConn & ";database=sampleMSDE.mdf" '

    Set cnConn = New adodb.Connection

    cnConn.Open sConn

    Set ADO_Connect = cnConn

ExitHandler:
    Exit Function

ErrorHandler:
    MsgBox Err.Description
    Resume ExitHandler

End Function



Mon, 01 Nov 2004 16:42:17 GMT  
 ADO Connection fails with 'sa'
Never mind...I figured it out.

Quote:
>-----Original Message-----
>MVP's-

>I have been learning ADO, and I have what I think might
>be a simple question.  With an ADP and MSDE, I have put
>forth the following code (which I believe works, however
>it is telling me that my login to the SQL Server
database
>fails with 'sa').

>[Microsoft][ODBC SQL Server Driver][SQL Server]login
>failed for user 'sa'.

>When I setup the database, I did not change the login (I
>left it as 'sa' with no password).  Is there a reason
>that a login would fail with 'sa'?  The ADP file IS
>accessing the tables already.

>Here is my code:

>Private Sub AddParameter_Click()
>On Error GoTo Err_AddParameter_Click

>Dim conn As adodb.Connection
>Dim strInsert As String
>Dim intGenericPart As Long

>Set conn = ADO_Connect

>MsgBox "connection is: " & conn.State

>intGenericPart = Forms![frmGenericPartDetail]!
>[GenericPartID]

>strInsert = "INSERT INTO tblRequirements (GenericPartID,
>ParameterID) VALUES (" & intGenericPart & ", " &
>Me.ParameterID & ")"

>conn.Execute (strInsert)

>Exit_AddParameter_Click:
>    Exit Sub

>Err_AddParameter_Click:
>    MsgBox Err.Description
>    Resume Exit_AddParameter_Click

>End Sub

>Here is the function:

>Function ADO_Connect() As adodb.Connection

>    Dim sConn       As String
>    Dim cnConn      As adodb.Connection

>    On Error GoTo ErrorHandler

>    sConn = "driver={SQL Server}"
>    sConn = sConn & ";server=mystation"  'my workstation
>and the Server name in the SQL Server Service manager
>    sConn = sConn & ";uid=sa"
>    sConn = sConn & ";pwd=''"
>    sConn = sConn & ";database=sampleMSDE.mdf" '

>    Set cnConn = New adodb.Connection

>    cnConn.Open sConn

>    Set ADO_Connect = cnConn

>ExitHandler:
>    Exit Function

>ErrorHandler:
>    MsgBox Err.Description
>    Resume ExitHandler

>End Function

>.



Mon, 01 Nov 2004 17:47:58 GMT  
 ADO Connection fails with 'sa'
CurrentProject.Connection.

--
MichKa

Michael Kaplan
Trigeminal Software, Inc.  -- http://www.trigeminal.com/

International VB? -- http://www.i18nWithVB.com/
C++? MSLU -- http://msdn.microsoft.com/msdnmag/issues/01/10/


Quote:
> MVP's-

> I have been learning ADO, and I have what I think might
> be a simple question.  With an ADP and MSDE, I have put
> forth the following code (which I believe works, however
> it is telling me that my login to the SQL Server database
> fails with 'sa').

> [Microsoft][ODBC SQL Server Driver][SQL Server]login
> failed for user 'sa'.

> When I setup the database, I did not change the login (I
> left it as 'sa' with no password).  Is there a reason
> that a login would fail with 'sa'?  The ADP file IS
> accessing the tables already.

> Here is my code:

> Private Sub AddParameter_Click()
> On Error GoTo Err_AddParameter_Click

> Dim conn As adodb.Connection
> Dim strInsert As String
> Dim intGenericPart As Long

> Set conn = ADO_Connect

> MsgBox "connection is: " & conn.State

> intGenericPart = Forms![frmGenericPartDetail]!
> [GenericPartID]

> strInsert = "INSERT INTO tblRequirements (GenericPartID,
> ParameterID) VALUES (" & intGenericPart & ", " &
> Me.ParameterID & ")"

> conn.Execute (strInsert)

> Exit_AddParameter_Click:
>     Exit Sub

> Err_AddParameter_Click:
>     MsgBox Err.Description
>     Resume Exit_AddParameter_Click

> End Sub

> Here is the function:

> Function ADO_Connect() As adodb.Connection

>     Dim sConn       As String
>     Dim cnConn      As adodb.Connection

>     On Error GoTo ErrorHandler

>     sConn = "driver={SQL Server}"
>     sConn = sConn & ";server=mystation"  'my workstation
> and the Server name in the SQL Server Service manager
>     sConn = sConn & ";uid=sa"
>     sConn = sConn & ";pwd=''"
>     sConn = sConn & ";database=sampleMSDE.mdf" '

>     Set cnConn = New adodb.Connection

>     cnConn.Open sConn

>     Set ADO_Connect = cnConn

> ExitHandler:
>     Exit Function

> ErrorHandler:
>     MsgBox Err.Description
>     Resume ExitHandler

> End Function



Tue, 02 Nov 2004 16:06:16 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. DLL's Calling DLL's for ADO Connection

2. Program won't close if connection fails with

3. sa can't access database ...

4. can't connect to sql server using sa

5. ADO-DataEnvironment failed to install on user'S PC

6. Install of VB app using ADO fails - can't register msado21.tlb

7. ADO connection passed to a DLL fails to maintain valid connection

8. ADO Stream Object - Method 'Open' of object '_Stream' failed

9. ADO control works while ADO Connection String fails

10. Method 'Result' of object FormField failed

11. Method 'Result' of Formfield failed

12. Login failed for user 'XYZ1492\IUSR_XYZ1492'

 

 
Powered by phpBB® Forum Software