question about ADO

question about ADO

Post by Albert LaPlan » Mon, 31 Jul 2000 04:00:00



Are you getting an error message or are the text boxes just not populating?

I'm not positive here but I believe you need to use the field name in the
.fields (?) instead of the .fields(index) for this particular assignment.
Something like this:

Text1.Text = .Fields(invhCde)     ' If invhCde is a number

     or

Text1.Text = Trim$(.Fields("invhCde") & "")   'If invhCde is a string

instead of

Text1.Text = .fields(0)

Albert



>hi, i'm new in ADO programming, i have written the following simple code,
>but it doesn't work:

>Private cnnMain As New ADODB.Connection
>Private cmdMain As New ADODB.Command
>Private rsMain As New ADODB.Recordset

>Private Sub Command1_Click()
>  With rsMain
>    .MovePrevious
>    If .BOF Then
>      .MoveFirst
>    End If
>  End With
>  fillForm
>End Sub

>Private Sub Command2_Click()
>  With rsMain
>    .MoveNext
>    If .EOF Then
>      .MoveLast
>    End If
>  End With
>  fillForm
>End Sub

>Private Sub Form_Load()
>  Dim dbSrc As String
>  Dim dbProv As String
>  Dim cnnStr As String

>  dbSrc = "tradpkcn.mdb"
>  dbProv = "Microsoft.Jet.OLEDB.4.0"

>  cnnStr = "Provider=" & dbProv & ";Data Source=" & dbSrc

>  cnnMain.Open cnnStr
>  cmdMain.ActiveConnection = cnnMain
>  cmdMain.CommandText = "SELECT * FROM tblInvh ORDER BY invhCde"

>  Set rsMain = cmdMain.Execute

>  fillForm
>End Sub

>Private Sub fillForm()
>  With rsMain
>    Text1.Text = .Fields(0)
>    Text2.Text = .Fields(1)
>    Text3.Text = .Fields(2)
>  End With
>End Sub

>is there any wrong with the code?

 
 
 

question about ADO

Post by Kwokh » Tue, 01 Aug 2000 04:00:00


hi, i'm new in ADO programming, i have written the following simple code,
but it doesn't work:

Private cnnMain As New ADODB.Connection
Private cmdMain As New ADODB.Command
Private rsMain As New ADODB.Recordset

Private Sub Command1_Click()
  With rsMain
    .MovePrevious
    If .BOF Then
      .MoveFirst
    End If
  End With
  fillForm
End Sub

Private Sub Command2_Click()
  With rsMain
    .MoveNext
    If .EOF Then
      .MoveLast
    End If
  End With
  fillForm
End Sub

Private Sub Form_Load()
  Dim dbSrc As String
  Dim dbProv As String
  Dim cnnStr As String

  dbSrc = "tradpkcn.mdb"
  dbProv = "Microsoft.Jet.OLEDB.4.0"

  cnnStr = "Provider=" & dbProv & ";Data Source=" & dbSrc

  cnnMain.Open cnnStr
  cmdMain.ActiveConnection = cnnMain
  cmdMain.CommandText = "SELECT * FROM tblInvh ORDER BY invhCde"

  Set rsMain = cmdMain.Execute

  fillForm
End Sub

Private Sub fillForm()
  With rsMain
    Text1.Text = .Fields(0)
    Text2.Text = .Fields(1)
    Text3.Text = .Fields(2)
  End With
End Sub

is there any wrong with the code?

thanks

 
 
 

question about ADO

Post by Kesh » Tue, 01 Aug 2000 04:00:00


Check fields values, may be it's null
IF Isnull(.Fields(0))=FALSE THEN  Text1.Text = .Fields(0) ELSE Text1.Text =
vbNullString


Quote:> hi, i'm new in ADO programming, i have written the following simple code,
> but it doesn't work:

> Private cnnMain As New ADODB.Connection
> Private cmdMain As New ADODB.Command
> Private rsMain As New ADODB.Recordset

> Private Sub Command1_Click()
>   With rsMain
>     .MovePrevious
>     If .BOF Then
>       .MoveFirst
>     End If
>   End With
>   fillForm
> End Sub

> Private Sub Command2_Click()
>   With rsMain
>     .MoveNext
>     If .EOF Then
>       .MoveLast
>     End If
>   End With
>   fillForm
> End Sub

> Private Sub Form_Load()
>   Dim dbSrc As String
>   Dim dbProv As String
>   Dim cnnStr As String

>   dbSrc = "tradpkcn.mdb"
>   dbProv = "Microsoft.Jet.OLEDB.4.0"

>   cnnStr = "Provider=" & dbProv & ";Data Source=" & dbSrc

>   cnnMain.Open cnnStr
>   cmdMain.ActiveConnection = cnnMain
>   cmdMain.CommandText = "SELECT * FROM tblInvh ORDER BY invhCde"

>   Set rsMain = cmdMain.Execute

>   fillForm
> End Sub

> Private Sub fillForm()
>   With rsMain
>     Text1.Text = .Fields(0)
>     Text2.Text = .Fields(1)
>     Text3.Text = .Fields(2)
>   End With
> End Sub

> is there any wrong with the code?

> thanks

 
 
 

question about ADO

Post by John E. Wilson Jr » Tue, 01 Aug 2000 04:00:00


I saw a neat trick the other day about NULL fields. Instead of checking for
NULLS just add nothing to the string  when you load the field. Like "
Text1.Text  = Text1.Text & "" & .Fields(0)  "


> Check fields values, may be it's null
> IF Isnull(.Fields(0))=FALSE THEN  Text1.Text = .Fields(0) ELSE Text1.Text
=
> vbNullString



> > hi, i'm new in ADO programming, i have written the following simple
code,
> > but it doesn't work:

> > Private cnnMain As New ADODB.Connection
> > Private cmdMain As New ADODB.Command
> > Private rsMain As New ADODB.Recordset

> > Private Sub Command1_Click()
> >   With rsMain
> >     .MovePrevious
> >     If .BOF Then
> >       .MoveFirst
> >     End If
> >   End With
> >   fillForm
> > End Sub

> > Private Sub Command2_Click()
> >   With rsMain
> >     .MoveNext
> >     If .EOF Then
> >       .MoveLast
> >     End If
> >   End With
> >   fillForm
> > End Sub

> > Private Sub Form_Load()
> >   Dim dbSrc As String
> >   Dim dbProv As String
> >   Dim cnnStr As String

> >   dbSrc = "tradpkcn.mdb"
> >   dbProv = "Microsoft.Jet.OLEDB.4.0"

> >   cnnStr = "Provider=" & dbProv & ";Data Source=" & dbSrc

> >   cnnMain.Open cnnStr
> >   cmdMain.ActiveConnection = cnnMain
> >   cmdMain.CommandText = "SELECT * FROM tblInvh ORDER BY invhCde"

> >   Set rsMain = cmdMain.Execute

> >   fillForm
> > End Sub

> > Private Sub fillForm()
> >   With rsMain
> >     Text1.Text = .Fields(0)
> >     Text2.Text = .Fields(1)
> >     Text3.Text = .Fields(2)
> >   End With
> > End Sub

> > is there any wrong with the code?

> > thanks

 
 
 

question about ADO

Post by JBCar » Tue, 01 Aug 2000 04:00:00


use !fields(n)


Quote:> hi, i'm new in ADO programming, i have written the following simple code,
> but it doesn't work:

> Private cnnMain As New ADODB.Connection
> Private cmdMain As New ADODB.Command
> Private rsMain As New ADODB.Recordset

> Private Sub Command1_Click()
>   With rsMain
>     .MovePrevious
>     If .BOF Then
>       .MoveFirst
>     End If
>   End With
>   fillForm
> End Sub

> Private Sub Command2_Click()
>   With rsMain
>     .MoveNext
>     If .EOF Then
>       .MoveLast
>     End If
>   End With
>   fillForm
> End Sub

> Private Sub Form_Load()
>   Dim dbSrc As String
>   Dim dbProv As String
>   Dim cnnStr As String

>   dbSrc = "tradpkcn.mdb"
>   dbProv = "Microsoft.Jet.OLEDB.4.0"

>   cnnStr = "Provider=" & dbProv & ";Data Source=" & dbSrc

>   cnnMain.Open cnnStr
>   cmdMain.ActiveConnection = cnnMain
>   cmdMain.CommandText = "SELECT * FROM tblInvh ORDER BY invhCde"

>   Set rsMain = cmdMain.Execute

>   fillForm
> End Sub

> Private Sub fillForm()
>   With rsMain
>     Text1.Text = .Fields(0)
>     Text2.Text = .Fields(1)
>     Text3.Text = .Fields(2)
>   End With
> End Sub

> is there any wrong with the code?

> thanks

 
 
 

1. Beginners questions regarding ADO 2.0

I have used dao to connect to data bases, but now wants to try out ADO 2.0
I find it hard to get hold of any beginners info regarding this subject. Can
some one please help me with the basic questions.
How do I..
1. Connecting to a Access *.mdb located on the users machine.
2. Using recordset to get all the data in the data base.
3. Assigning this data to a combo or text box on a form.

Johan Lundberg Gothenburg Sweden

2. PDOX 4.0 DOS under windows 95

3. 2 related questions re ADO disconnected recprdsets.

4. ADo Control cannot fetch backwards . Urgent

5. beginner question bout ado object and scope

6. SQL Query Question

7. Simple Question With ADO

8. pirat copys searched

9. a question regarding ado

10. A long question about ADO recordsets and DCOM problems

11. Question about ADO on Windows XP

12. question about ado save to xml

13. Question about ADO recordset and AddNew