|
-
Apr 28th, 2000, 11:24 PM
#1
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
-
Apr 29th, 2000, 04:45 AM
#2
Member
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.
-
May 3rd, 2000, 07:11 AM
#3
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?
-
May 3rd, 2000, 12:59 PM
#4
Lively Member
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??
-
May 4th, 2000, 08:12 AM
#5
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|