D
dennist
please excuse my last post on this which was improperly
formatted due to a utility(text cleaner) that I had
active.
My problem is that I read ado.net step by step, including
working out all the examples.
In the end, I still can't create generic procedures in
classes and modules.
I'm going to give you part of an example from vb 6, and
ask if you can show me how to do such things in ado.net
Private Sub Form_Load()
'InitcboQualifier
'Set clsTFSADO = New clsADO
Dim lPrntID As Long
Dim sItemText As String
lPrntID = clsTFSADO.ParntID
Me.Save0 = False
txtTopicTitle.Text = ""
mskDate = Date
cmdSaveLOG.Enabled = True
ComboBoxConnection
'SetcboQualifier "POV", "PermissionID"
clsTFSADO.FillComboBox cboTopicIssuer, "SELECT
TopicIssuers.* FROM TopicIssuers ORDER BY
TopicIssuers.Issuer;", 2
clsTFSADO.FillComboBox cboPublication, "SELECT
Publications.ID, Publications.Publication FROM
Publications ORDER BY Publications.Publication;", 2
sItemText = GetItemText(cboTopicIssuer, cboPublication)
' clsTFSADO.FillListBox lstAuthors, "SELECT Authors.ID,
Authors.[Last Name], Authors.[First Name] AS Name FROM
Authors ORDER BY Authors.[Last Name], Authors.[First
Name];", 1
clsTFSADO.FillListBox lstAuthors, "SELECT Authors.ID,
Authors.[Last Name], Authors.[First Name] FROM Authors
ORDER BY Authors.[Last Name], Authors.[First Name];", 1
sItemText = clsTFSADO.GetLItemText(cboPublication,
lstAuthors)
clsTFSADO.FillComboBox cboPOV, "SELECT PointsOfView.ID, "
& "PointsOfView.PointOfView FROM PointsOfView ORDER BY
PointsOfView.PointOfView;", 2
sItemText = GetTextFromItemData(cboPublication, cboPOV)
' clsTFSADO.FillComboBox cboPOV1, "SELECT
PointsOfView.ID, PointsOfView.PointOfView FROM
PointsOfView ORDER BY PointsOfView.PointOfView;", 2
' sItemText = GetTextFromItemData(cboPublication,
cboPOV1)
txtPermission.Text = 6
POVTopicIssuer = False
clsTFSADO.FillComboBox cboDateType, "SELECT DateType.ID,
DateType.DateType FROM DateType ORDER BY
DateType.DateType;", 2
cboTopicIssuer.ListIndex = 7
cboPublication.ListIndex = 2
cboPOV.ListIndex = 12
cboDateType.ListIndex = 6
End Sub
Private Sub cmdSaveLOG_Click()
If cboTopicIssuer.ListIndex = -1 Then
MsgBox "No Topic Issuer selected."
CboTopicIssuer.SetFocus
Exit Sub
ElseIf cboPublication.ListIndex = -1 Then
MsgBox "No Publisher selected."
CboPublication.SetFocus
Exit Sub
ElseIf cboPOV.ListIndex = -1 Then
MsgBox "No Point of View selected."
CboPOV.SetFocus
Exit Sub
ElseIf txtPermission.Text <> "6" Then txtPermission = "6"
Exit Sub
ElseIf cboDateType.ListIndex = -1 Then
MsgBox "No Date Type is selected."
CboDateType.SetFocus
Exit Sub
ElseIf Not IsDate(mskDate.Text) Then
MsgBox "The date box does not contain a date."
MskDate.SetFocus
Exit Sub
ElseIf txtTopicText.Text = "" Then
MsgBox "There is no topic text."
CmdOpenFile.SetFocus
Exit Sub
End If
Set gForm = Me
' gsTopicText = txtTopicText.Text
txtTopicText.Locked = True
txtTopicText.BackColor = &HE0E0E0
txtTopicText1.Text = gsTopicText
txtTopicText1.Locked = True
txtTopicText2.Text = gsTopicText
txtTopicText2.Locked = True
UpDateTopic
cmdSaveLOG.Enabled = False
gID = Clng(txtID.Text)
End Sub
In ClsADO
Public Sub FillLBox(lbox As ListBox, iState As Integer)
Dim s As String
Select Case iState
Case 0, 3
While Not cboRS.EOF
s = Trim(cboRS.Fields(1))
lbox.AddItem s lbox.ItemData(lbox.NewIndex) = cboRS.Fields
(0) cboRS.MoveNext
Wend
Case 1
While Not cboRS.EOF
s = Trim(cboRS.Fields(1))
If Len(Trim(cboRS.Fields(2))) = 0 Then
Else s = s & ", " & Trim(cboRS.Fields(2))
End If
lbox.AddItem s
lbox.ItemData(lbox.NewIndex) = cboRS.Fields(0)
cboRS.MoveNext
Wend
Case Else
End Select
End Sub
In modDataChroreography
Public Function UpDateTopic() As Boolean
On Error GoTo Error1
Dim sConn As String
Dim TopicRS As Recordset
'sConn = ConnString
= "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source= " &
App.Path & "\hasbarasample.mdb;"
UpDateTopic = False
Set TopicRS = New Recordset
TopicRS.Open "Topics", gsConnString, adOpenDynamic,
adLockOptimistic TopicRS.AddNew
TopicRS("ParentID") = gForm.txtParentID.Text
TopicRS("Title") = gForm.txtTopicTitle.Text TopicRS
("Text") = gForm.txtTopicText.Text
TopicRS("Issuer") = GetItem(gForm.cboTopicIssuer)
TopicRS("Length") = Len(gForm.txtTopicText.Text)
TopicRS("PointOfView") = GetItem(gForm.cboPOV)
TopicRS("PermissionID") = 6
TopicRS("Publisher") = GetItem(gForm.cboPublication)
TopicRS.Update
TopicRS.MoveLast
gForm.txtID.Text = Cstr(TopicRS.Fields(0))
UpDateTopic = True
TopicRS.Close
Set TopicRS = Nothing
Exit Function
Error1: Select Case Err.Number
Case -2147217887, 379 'MsgBox Cstr(TopicRS.Fields(0))
Exit Function
Case Else Exit Function
End Select
End Function
thank you very much.
dennisty
formatted due to a utility(text cleaner) that I had
active.
My problem is that I read ado.net step by step, including
working out all the examples.
In the end, I still can't create generic procedures in
classes and modules.
I'm going to give you part of an example from vb 6, and
ask if you can show me how to do such things in ado.net
Private Sub Form_Load()
'InitcboQualifier
'Set clsTFSADO = New clsADO
Dim lPrntID As Long
Dim sItemText As String
lPrntID = clsTFSADO.ParntID
Me.Save0 = False
txtTopicTitle.Text = ""
mskDate = Date
cmdSaveLOG.Enabled = True
ComboBoxConnection
'SetcboQualifier "POV", "PermissionID"
clsTFSADO.FillComboBox cboTopicIssuer, "SELECT
TopicIssuers.* FROM TopicIssuers ORDER BY
TopicIssuers.Issuer;", 2
clsTFSADO.FillComboBox cboPublication, "SELECT
Publications.ID, Publications.Publication FROM
Publications ORDER BY Publications.Publication;", 2
sItemText = GetItemText(cboTopicIssuer, cboPublication)
' clsTFSADO.FillListBox lstAuthors, "SELECT Authors.ID,
Authors.[Last Name], Authors.[First Name] AS Name FROM
Authors ORDER BY Authors.[Last Name], Authors.[First
Name];", 1
clsTFSADO.FillListBox lstAuthors, "SELECT Authors.ID,
Authors.[Last Name], Authors.[First Name] FROM Authors
ORDER BY Authors.[Last Name], Authors.[First Name];", 1
sItemText = clsTFSADO.GetLItemText(cboPublication,
lstAuthors)
clsTFSADO.FillComboBox cboPOV, "SELECT PointsOfView.ID, "
& "PointsOfView.PointOfView FROM PointsOfView ORDER BY
PointsOfView.PointOfView;", 2
sItemText = GetTextFromItemData(cboPublication, cboPOV)
' clsTFSADO.FillComboBox cboPOV1, "SELECT
PointsOfView.ID, PointsOfView.PointOfView FROM
PointsOfView ORDER BY PointsOfView.PointOfView;", 2
' sItemText = GetTextFromItemData(cboPublication,
cboPOV1)
txtPermission.Text = 6
POVTopicIssuer = False
clsTFSADO.FillComboBox cboDateType, "SELECT DateType.ID,
DateType.DateType FROM DateType ORDER BY
DateType.DateType;", 2
cboTopicIssuer.ListIndex = 7
cboPublication.ListIndex = 2
cboPOV.ListIndex = 12
cboDateType.ListIndex = 6
End Sub
Private Sub cmdSaveLOG_Click()
If cboTopicIssuer.ListIndex = -1 Then
MsgBox "No Topic Issuer selected."
CboTopicIssuer.SetFocus
Exit Sub
ElseIf cboPublication.ListIndex = -1 Then
MsgBox "No Publisher selected."
CboPublication.SetFocus
Exit Sub
ElseIf cboPOV.ListIndex = -1 Then
MsgBox "No Point of View selected."
CboPOV.SetFocus
Exit Sub
ElseIf txtPermission.Text <> "6" Then txtPermission = "6"
Exit Sub
ElseIf cboDateType.ListIndex = -1 Then
MsgBox "No Date Type is selected."
CboDateType.SetFocus
Exit Sub
ElseIf Not IsDate(mskDate.Text) Then
MsgBox "The date box does not contain a date."
MskDate.SetFocus
Exit Sub
ElseIf txtTopicText.Text = "" Then
MsgBox "There is no topic text."
CmdOpenFile.SetFocus
Exit Sub
End If
Set gForm = Me
' gsTopicText = txtTopicText.Text
txtTopicText.Locked = True
txtTopicText.BackColor = &HE0E0E0
txtTopicText1.Text = gsTopicText
txtTopicText1.Locked = True
txtTopicText2.Text = gsTopicText
txtTopicText2.Locked = True
UpDateTopic
cmdSaveLOG.Enabled = False
gID = Clng(txtID.Text)
End Sub
In ClsADO
Public Sub FillLBox(lbox As ListBox, iState As Integer)
Dim s As String
Select Case iState
Case 0, 3
While Not cboRS.EOF
s = Trim(cboRS.Fields(1))
lbox.AddItem s lbox.ItemData(lbox.NewIndex) = cboRS.Fields
(0) cboRS.MoveNext
Wend
Case 1
While Not cboRS.EOF
s = Trim(cboRS.Fields(1))
If Len(Trim(cboRS.Fields(2))) = 0 Then
Else s = s & ", " & Trim(cboRS.Fields(2))
End If
lbox.AddItem s
lbox.ItemData(lbox.NewIndex) = cboRS.Fields(0)
cboRS.MoveNext
Wend
Case Else
End Select
End Sub
In modDataChroreography
Public Function UpDateTopic() As Boolean
On Error GoTo Error1
Dim sConn As String
Dim TopicRS As Recordset
'sConn = ConnString
= "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source= " &
App.Path & "\hasbarasample.mdb;"
UpDateTopic = False
Set TopicRS = New Recordset
TopicRS.Open "Topics", gsConnString, adOpenDynamic,
adLockOptimistic TopicRS.AddNew
TopicRS("ParentID") = gForm.txtParentID.Text
TopicRS("Title") = gForm.txtTopicTitle.Text TopicRS
("Text") = gForm.txtTopicText.Text
TopicRS("Issuer") = GetItem(gForm.cboTopicIssuer)
TopicRS("Length") = Len(gForm.txtTopicText.Text)
TopicRS("PointOfView") = GetItem(gForm.cboPOV)
TopicRS("PermissionID") = 6
TopicRS("Publisher") = GetItem(gForm.cboPublication)
TopicRS.Update
TopicRS.MoveLast
gForm.txtID.Text = Cstr(TopicRS.Fields(0))
UpDateTopic = True
TopicRS.Close
Set TopicRS = Nothing
Exit Function
Error1: Select Case Err.Number
Case -2147217887, 379 'MsgBox Cstr(TopicRS.Fields(0))
Exit Function
Case Else Exit Function
End Select
End Function
thank you very much.
dennisty