I''m unable to connect to my newly created database.

  • A newbie request here.

    With the help of this forum I've been able to progress to where I am now, but I've got stuck again.

    Basically, I want my 'Local' web page to display information from my 'Local' SQL database. I'm getting this error message;

    Microsoft OLE DB Provider for SQL Server (0x80040E4D)

    Login failed for user 'sa'.

    /Books/Logon_validate_code.asp, line 34

    Now I can see that it states that the user is 'sa', so I went into my SQL 2000 Enterprise Manager --> Security --> Logins --> sa --> Database Access Tab and it says that 'sa' has access to my database called Books.

    I thought that I had set the Logins and Roles correctly, but I'm open to advise.

    I realise that the question of ' database connections' has many possible answers, but I'm only after a simple sonnection to my 'local' server.

    Thank you

    Alan

  • Well I can think of 2 things :

    1 - Are you sure you have the right password for the sa account?

    --most likely

    2 - Is the authentication mode windows only or windows + sql logins??

  • Well, after much trial and error, I finally achieved what I wanted to do, which was use ASP to connect to an SQL database, extract some details from them and print the results to screen via a browser.

     

    I hope this may help some other Newbies, like me, to start the ball rolling with SQL.

     

     

    Create a new file called global.asa (it has to be this name!!) and type in this code;

     

    <SCRIPT LANGUAGE=VBScript RUNAT=Server>

           Sub Application_OnStart

                       Application("ConnectionString") = "Driver={SQL Server};Server=(local);UID=Administrator;PWD=bbunter;Database=Comics UK;"

           End Sub

    </SCRIPT>

     

    Change the bolded values to your own SQL setup. Save the file and then create a new file called index.asp and type this code in the HEAD section;

     

    Set Conn = Server.CreateObject("ADODB.Connection")

    Conn.Open Application("ConnectionString")

    Set getRows = Conn.Execute("SELECT * FROM GenreDB")

     

    Do Until getRows.eof

           Response.Write getRows("GenreID") & "   " & getRows("GenreType")

           getRows.MoveNext

    Loop

    Conn.Close

     

    Change the bolded values to the contents of the table from your database and the columns from your tables.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply