Click here to Skip to main content
15,894,180 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
here is the error

<img src="http://i1248.photobucket.com/albums/hh498/tsenilas/wtf.jpg" border="0" alt="Photobucket"/>


here are the codes.

VB
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!!!"
    Else
        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
Updated 6-Dec-12 3:01am
v2

1 solution

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.
 
Share this answer
 
Comments
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?

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900