Connecting to SQL database from within Class Library

Hi there,
I am trying to connect my ClassLibrary to a SQL database.
I've already added a new datasource (named PatientsDS_new) to my database, I've let VB copy it to local project etc. .
The database contains a table (names patients), which is imported too.
This is also the table I want to perform actions on.

Now the problem is that in 'form applications', i can select a row like this:
Dim row As patientsDSx.patients_1Row = Me.PatientsDSx.patients_1.FindByPatientID(id)
But in my 'ClassLibrary' I can only get to this:
Dim row As patientsDS_new.patients_1Row
I want to be able to do the same as in my form-code, but I don't know how to achieve this.

This is the code I am using:

Public Sub SaveToDB(ByVal opt As String, ByVal id As Integer, ByVal lastname As String, ByVal firstname As String, ByVal address As String, _
ByVal city As String, ByVal zip As String, ByVal telnr As String, ByVal gsmnr As String, _
ByVal notes As String, ByVal lastvisit As String, ByVal bloodgroup As String, ByVal doctor As String, _
ByVal hif As String, ByVal regnr As String, ByVal bd As Date, ByVal age As String, _
ByVal visits As String, ByVal debts As String)
opt = opt.ToLower
Select Case opt
Case "add"
Dim age_ As Integer = DateDiff(DateInterval.Year, bd, Now)
Dim row As patientsDS_new.patients_1Row ' This has to change
row.BeginEdit()
row.LastName = lastname
row.FirstName = firstname
row.Address = address
row.City = city
row.ZIP = zip
row.TelNr = telnr
row.GSMNr = gsmnr
row.Notes = notes
row.LastVisit = lastvisit
row.BloodGroup = bloodgroup
row.Doctor = doctor
row.HIF = hif
row.RegNr = regnr
row.BirthDate = bd
row.Age = age_
row.Visits = visits
row.Debts = debts
row.AcceptChanges()
row.EndEdit()
End Select
End Sub

Any help would be welcome.
Grtz, Tom.




Answer this question

Connecting to SQL database from within Class Library