Click here to Skip to main content
12,550,447 members (45,164 online)
Rate this:
Please Sign up or sign in to vote.
See more: SQL-server-2005 VB SQL-Server , +
here is the error

<img src="" border="0" alt="Photobucket"/>

here are the codes.

    Private Sub btnAddDoc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddDoc.Click
        If txtDocID.Text = "" OrElse txtDocName.Text = "" OrElse txtDocType.Text = "" Then
            lblNotice.Text = "PLEASE COMPLETE ALL THE REQUIRED FIELDS!!!"
            If btnAddDoc.Text = "Add Document" Then
                Dim connstring As String = "Provider=SQLOLEDB;Data Source=RONALDAMIT-PC;Integrated Security=SSPI;Initial Catalog=UEP Document Logbook"
                Dim conn As New ADODB.Connection()
                conn.ConnectionString = connstring
                conn.Open(Nothing, Nothing, Nothing, -1)
                Dim rs As New ADODB.Recordset()
                Dim sql As String = "Insert into AddDocument (DocID,DocName,Doctype) values ('" + txtDocID.Text + "', '" + txtDocName.Text + "', '" + txtDocType.Text + "')"
                rs.Open(sql, conn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly, -1)
                MessageBox.Show("Document Added")
            End If
        End If
    End Sub>
Posted 6-Dec-12 2:59am
Updated 6-Dec-12 3:01am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

The error message is pretty clear - and it would help a lot if you learn to use copy and paste of text rather than taking a screen shot and posting a link to that.

"Cannot open database UEP Document Logbook as requested by the login"
Check your connection string. Try setting up a connection in VS with the Server Explorer pane:
1) Open Server Explorer.
2) Right click "Data connections" and select "Add connection"
3) In the dialog that follows, select your DataSource, and database, specify the security info, and press the "Test connection" button.
4) When the connection works, press "OK"
5) Highlight your database in the Server Explorer pane, and look at the Properties pane. A working example of the connection string will be shown, which you can copy and paste into your app or config file.
Ronald Amit 6-Dec-12 13:22pm
I keep getting an "Error 26" every time I try to do you instruction number 1.. what do I do?
Ronald Amit 6-Dec-12 13:32pm
it says Cannot connect to RONALDAMIT-PC/SQLEXPRESS.. a few weeks ago I have been using this database engine.. and now it just wont work..
OriginalGriff 6-Dec-12 14:00pm
Assuming you have fixed the "Error 26" problem (or you wouldn't have posted your second message)
If it can't connect to "RONALDAMIT-PC/SQLEXPRESS" then probably, you have spelled it wrong. Open Sql Server Management Studio (SSMS for short) and look at the server name it defaults to on the login screen.
Ronald Amit 6-Dec-12 21:36pm
that is the default server name the "RONALDAMIT-PC/SQLEXPRESS"
OriginalGriff 7-Dec-12 3:42am
And did SSMS connect ok? If so, what login info did you use?
Ronald Amit 7-Dec-12 12:36pm
No, it did not. it gave me the "Error 26"
OriginalGriff 7-Dec-12 14:02pm
Then the name is wrong.
SQL Error 26 is "Error Locating Server/Instance Specified" - so try browsing for network versions via the startup Connect screen to at least pickup the name of the pc hosting the service.
Ronald Amit 8-Dec-12 19:40pm
okay, its connected now. i just clicked the browse option and found another server without the "SQLEXPRESS" .. but I'm still getting the same errors.. what now?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.161021.1 | Last Updated 6 Dec 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100