Results 1 to 15 of 15

Thread: [RESOLVED] Data environment and Data report

  1. #1

    Thread Starter
    Lively Member nthski's Avatar
    Join Date
    Aug 2014
    Posts
    83

    Resolved [RESOLVED] Data environment and Data report

    How to connect in msaccess that has a ms acess pasword pls help me thanks

  2. #2
    Frenzied Member
    Join Date
    Feb 2003
    Posts
    1,807

    Re: Data environment and Data report

    I assume you are not just opening the file in MSAccess but are trying to connect to it from another file? Are you using Microsoft ADO? Could you post the code you're using for the connection here?

  3. #3

    Thread Starter
    Lively Member nthski's Avatar
    Join Date
    Aug 2014
    Posts
    83

    Re: Data environment and Data report

    Quote Originally Posted by Peter Swinkels View Post
    I assume you are not just opening the file in MSAccess but are trying to connect to it from another file? Are you using Microsoft ADO? Could you post the code you're using for the connection here?
    Ok thanks hmm later ill post ss and code actually in my data environment i dont use any code i just set up in properties now i want my data environment and data report that can connect to my mdb with password because i want my system run and other people cant edit mdb file

  4. #4
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Data environment and Data report

    A DataEnvironment has one or more Connections. User and password are specified on each Connection.

    DataEnvironments like most new data access components in VB6 use ADO, and as such can only use ODBC drivers via the ODBC shim Provider.

  5. #5

    Thread Starter
    Lively Member nthski's Avatar
    Join Date
    Aug 2014
    Posts
    83

    Re: Data environment and Data report

    Dim conString As String

    conString = "Provider=Microsoft.Jet.OLEDB.4.0;" _
    & "Data Source=" & App.Path & "/DataBase/InvData.mdb" _
    & ";;Jet OLEDBatabase Password=nthski;"

    cn.Open conString

  6. #6

    Thread Starter
    Lively Member nthski's Avatar
    Join Date
    Aug 2014
    Posts
    83

    Re: Data environment and Data report

    connecting from data environment to msaccess that without pass is success if I put an password in msaccess data environment cant be connected pls help me

  7. #7
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Data environment and Data report

    Hmm, are you having trouble with a Jet share-level password? This isn't the best way to secure a database but it works just fine for simple situations.

    If you want to simply hard-code the value it doesn't take much, you just need to set it in the right place:

    Name:  sshot1.png
Views: 186
Size:  17.2 KB


    Once the password has been set there, you can go ahead and test the connection:

    Name:  sshot2.png
Views: 167
Size:  16.9 KB


    But if you want the user to enter it at runtime you have to get a little tricky. As far as I know there isn't a shortcut for this.

    In the attached demo I have used a "main form" Form1, but I have the program start by loading a "password form" Form0 to accept the password and apply it. Here's the code in Form0:

    Code:
    Option Explicit
    
    Private Sub cmdCancel_Click()
        Unload Me
    End Sub
    
    Private Sub cmdOk_Click()
        With DataEnvironment1.Connection1
            With .Properties
                ![Prompt].Value = adPromptNever
                ![Jet OLEDB:Database Password].Value = Trim$(txtPW.Text)
            End With
            On Error Resume Next
            .Open
            If Err Then
                MsgBox "Incorrect password"
                txtPW.Text = ""
                txtPW.SetFocus
                Exit Sub
            End If
            On Error GoTo 0
        End With
        Form1.Show
        Unload Me
    End Sub
    Seems to work just fine.

    To try the demo you should be able to just unZIP the archive and open the VBP in the VB6 IDE and run it. The required password is given in a "hint" shown in Form0 ("supersecret").
    Attached Files Attached Files

  8. #8

    Thread Starter
    Lively Member nthski's Avatar
    Join Date
    Aug 2014
    Posts
    83

    Re: Data environment and Data report

    Quote Originally Posted by dilettante View Post
    Hmm, are you having trouble with a Jet share-level password? This isn't the best way to secure a database but it works just fine for simple situations.

    If you want to simply hard-code the value it doesn't take much, you just need to set it in the right place:

    Name:  sshot1.png
Views: 186
Size:  17.2 KB


    Once the password has been set there, you can go ahead and test the connection:

    Name:  sshot2.png
Views: 167
Size:  16.9 KB


    But if you want the user to enter it at runtime you have to get a little tricky. As far as I know there isn't a shortcut for this.

    In the attached demo I have used a "main form" Form1, but I have the program start by loading a "password form" Form0 to accept the password and apply it. Here's the code in Form0:

    Code:
    Option Explicit
    
    Private Sub cmdCancel_Click()
        Unload Me
    End Sub
    
    Private Sub cmdOk_Click()
        With DataEnvironment1.Connection1
            With .Properties
                ![Prompt].Value = adPromptNever
                ![Jet OLEDB:Database Password].Value = Trim$(txtPW.Text)
            End With
            On Error Resume Next
            .Open
            If Err Then
                MsgBox "Incorrect password"
                txtPW.Text = ""
                txtPW.SetFocus
                Exit Sub
            End If
            On Error GoTo 0
        End With
        Form1.Show
        Unload Me
    End Sub
    Seems to work just fine.

    To try the demo you should be able to just unZIP the archive and open the VBP in the VB6 IDE and run it. The required password is given in a "hint" shown in Form0 ("supersecret").
    thanks tthnks sir

  9. #9

    Thread Starter
    Lively Member nthski's Avatar
    Join Date
    Aug 2014
    Posts
    83

    Re: Data environment and Data report

    hmmm I get an idea in form0 I will make an trick automatic connect to database
    just change the properties of txtPW.Text = password of your database
    the user will not notice that system has a password in database I think it more secure ^^ thanks sir it helps me a lot now my project on thesis almost 90% done if you want I can share with you ^^
    Private Sub Form_Load()
    With DataEnvironment1.Connection1
    With .Properties
    ![Prompt].Value = adPromptNever
    ![Jet OLEDBatabase Password].Value = Trim$(txtPW.Text)
    End With
    Form1.Show
    Unload Me
    end sub

  10. #10

    Thread Starter
    Lively Member nthski's Avatar
    Join Date
    Aug 2014
    Posts
    83

    Re: Data environment and Data report

    Name:  Untitled.jpg
Views: 165
Size:  46.0 KB

    n error

  11. #11
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Data environment and Data report

    Can't read the error message, If you want to post the screen that the error is on you should crop it to where it is just the msgbox so that it does not get scaled down so small, no need for all that other stuff in there and can't read the important part.

  12. #12

    Thread Starter
    Lively Member nthski's Avatar
    Join Date
    Aug 2014
    Posts
    83

    Re: Data environment and Data report

    Quote Originally Posted by DataMiser View Post
    Can't read the error message, If you want to post the screen that the error is on you should crop it to where it is just the msgbox so that it does not get scaled down so small, no need for all that other stuff in there and can't read the important part.
    The error mssg is "read only property value was not set"

  13. #13
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Data environment and Data report

    Hard to diagnose from here with so little information.

    Perhaps you tried to set the password value after the Connection was already open, or already bound to a control?

    This was why I used a Form0 to handle the process, before Form1 which uses the DataEnvironment was ever loaded. You could probably also do this in Form1 by breaking the design-time data binding (for example deleting DataMember) and then setting it at runtime after setting the password.

  14. #14

    Thread Starter
    Lively Member nthski's Avatar
    Join Date
    Aug 2014
    Posts
    83

    Re: Data environment and Data report

    Quote Originally Posted by dilettante View Post
    Hard to diagnose from here with so little information.

    Perhaps you tried to set the password value after the Connection was already open, or already bound to a control?

    This was why I used a Form0 to handle the process, before Form1 which uses the DataEnvironment was ever loaded. You could probably also do this in Form1 by breaking the design-time data binding (for example deleting DataMember) and then setting it at runtime after setting the password.
    Sir thanks for the help atm im not infront of my loptop i was thinking maybe i found the solution in my module i have an function submain which contain of connecting to my database i was thinking that may code has conflict with this later ill post the result ^_^

  15. #15

    Thread Starter
    Lively Member nthski's Avatar
    Join Date
    Aug 2014
    Posts
    83

    Re: Data environment and Data report

    datamiser and dilettante thanks both of you guys I found out the solution of my problem here guys I share with you about on How to connect in msaccess that has a ms acess pasword in data environment and data report
    create 1 form contain in command button I name it cmdprint then in data report name it rptperson and database I name it invdata inside database create a table I name it EmpMaster and it has the ff fields EmpName , Desig , Add, City, Phone, Mobile
    Create 1 module
    Code:
    Sub Main()
    
    
        On Error GoTo errConn
    
        Set cn = New ADODB.Connection
    Dim conString As String
    
         conString = "Provider=Microsoft.Jet.OLEDB.4.0;" _
              & "Data Source=" & App.Path & "/DataBase/InvData.mdb" _
              & ";;Jet OLEDB:Database Password=nthski;"
    
         cn.Open conString
    
    form1.Show
        Exit Sub
    errConn:
        MsgBox Err.Description
        End
    
    End Sub
    
    'code in form1
    
    Private Sub cmdprint_Click()
    
         Set rec = New ADODB.Recordset
     rec.Open "select * from EmpMaster where EmpName = '" & txtName.Text & "' ", cn, adOpenStatic, adLockOptimistic
       'search = "SELECT * FROM EmpMaster WHERE EmpName = '" & searching & "'"
       
     
       If rec.RecordCount > 0 Then
           
          
           With rptperson
            
            Set rptperson.Sections("Section1").Controls("Image1").Picture = LoadPicture(txtPath.Text)
            Set rptperson.DataSource = rec
           .Sections("Section1").Controls("txtname").DataField = "EmpName"
           .Sections("Section1").Controls("txtDesig").DataField = "Desig"
           .Sections("Section1").Controls("txtAddress").DataField = "Add"
           .Sections("Section1").Controls("txtCity").DataField = "City"
           .Sections("Section1").Controls("txtPhone").DataField = "Phone"
           .Sections("Section1").Controls("txtMobile").DataField = "Mobile"
       .Show
       End With
        End If
    create 1 report that has a rpttextbox name it txtname , txtDesig, txtAddress, txtCity, txtPhone, txtMobile

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width