Results 1 to 5 of 5

Thread: dll best way

  1. #1
    Guest
    I am currently writting a database application

    I would like to take the code from my public module and place it into a dll for future programs... I recieve errors... Will I have to pass all values into the dll functions and return each set of values that I want to load into a form into a variable first for it to work properly?


    Public strMsg
    Public Cn As Connection
    Public Rs As New Recordset
    Public strJet As String


    Public Function DBPath(dbName as string)
    Dim strDBPath
    strDBPath = App.Path
    If Right(strDBPath, 1) <> "\" Then
    strDBPath = strDBPath + "\" dbName +";Persist Security Info=False"
    End If
    strJet = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strDBPath


    End Function

    Public Function OpenDb(strPath as String)
    ' Close an open connection
    If Not (Cn Is Nothing) Then
    Cn.Close
    Set Cn = Nothing
    End If
    ' Create a new connection Set Cn = New Connection
    With Cn
    ' To connect to a SQL Server, use the following line:
    ' .ConnectionString="driver=[SQL Server];uid=admin;server=mysrv;database=site"
    ' For this example, we will be connecting to a local database
    .ConnectionString = strPath
    .CursorLocation = adUseClient
    .Open
    End With
    End Function



  2. #2
    Member
    Join Date
    Jan 1999
    Posts
    41
    I am not sure that I got your question right?
    What is Persist Security information in your path?
    The "\" and dbName do not have any operator between them?

    As soon as I changed it to
    strDBPath = strDBPath & dbName & ";Persist Security Info=False"
    everything went find. Although I cannot be sure that it is
    correct since I did not quite understand your question.



  3. #3
    Guest
    Sorry bout that forgot to paste one of the functions...

    The problem is not the dbpath function... I have that function and others running in a public module now... what is the best way to build a dll that I can use with all my new programs without having to create everthing with the same form name or modifying the code like this function here

    Public Function AddSkill()
    With Rs
    .AddNew
    .Fields("fldCharID").Value = frmMain.grdChar.TextMatrix(frmMain.grdChar.Row, 0)
    .Fields("fldSkill").Value = frmAddSkills.txtSkillName.Text
    .Fields("fldDice").Value = frmAddSkills.txtDice.Text
    .Fields("fldPip").Value = frmAddSkills.txtPip.Text
    .Update
    .Requery
    .Close
    End With

    LoadCharSkills frmMain.grdChar.TextMatrix(frmMain.grdChar.Row, 0)
    Rs.Open "SELECT * FROM " & TableName, Cn, adOpenKeyset, adLockOptimistic

    End Function

    Basically is there a way to pass in the form name and control as a parameter?


  4. #4
    Lively Member
    Join Date
    Aug 1999
    Posts
    89
    I don't really get what you mean.
    But i guess you are trying to put all the values you get from a form into a dll and retrieve values from database then return the values??

    If that's the case, You can create a function that gets all the input and return as an recordset. e.g.:

    Function Process(a as string,...) as recordset
    dim rs as recordset
    .
    .
    .
    set process=rs
    end function

    Or you can pass in the whole form such as:

    Function Process(a as form) as recordset
    dim rs as recordset
    .
    .
    .
    set process=rs
    end function

    Hope this is what you want??

  5. #5
    Guest
    Now that might work... I didn't think of passing the whole form in.... the problem is I have functions that open certain recordsets depending on the parameters I pass... now what I want to do is to be able to load these values into a form from a dll... since the dll needs the form name and control name I needed to know how I could pass this info into the dll function if I wanted to link it to another program... I'll try passing the whole form and see if that works....


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