Database Access

  • Thread starter Thread starter Hotrod2000
  • Start date Start date
H

Hotrod2000

Has anyone used the following code from SAMS A Programmer's
Introdution to Visual Basic.NET Pg 118 :-

Protected Sub cboCountry_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs)
dsCustomers1.Clear()
Dim con As New Component1
conMe.FillCustomersDataSet(dsCustomers1, cboCountry.Text)
End Sub

As when I've tried to use this I get the error "Name conMe is not
declared" which makes sense as I can't find where it is declared !!!
but I don't know how or where it needs declaring ??

Any help would be appreciated.

Cheers
 
Hotrod2000 said:
Has anyone used the following code from SAMS A Programmer's
Introdution to Visual Basic.NET Pg 118 :-

Protected Sub cboCountry_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs)
dsCustomers1.Clear()
Dim con As New Component1
conMe.FillCustomersDataSet(dsCustomers1, cboCountry.Text)
End Sub

As when I've tried to use this I get the error "Name conMe is not
declared" which makes sense as I can't find where it is declared !!!
but I don't know how or where it needs declaring ??

It looks like you need to take the "Me" out of it.

Andrew
 
It looks like you need to take the "Me" out of it.

Andrew

Hi Andrew,

Thanks !! I've tried that but I now get a different error message:-
Too many arguments to 'Public Function FillCustomersDataSet() as
dsCustomers'
Any ideas ?
 
Hotrod,

As this is in the book, then the writter has probably tried to show how good
he is.

However the code you see is in my idea not something as an Introduction to
Visual Basic.Net

jmo

Cor
 
For the second error, you need to go back to the definition of the
FillCustomersDataSet method for the Component1 class to see the arguments it
requires. I can't find any such member. From the comments following the
example, it is apparent that he actually meant FillDataSet. However, the
only methods he has defined for Component1 are FillCustomers (a function)
and UpdateCustomers. FillCustomers defines the ds to be used as Customers,
so I don't believe the call would require the dataset name to be passed.
Therefore, it looks like he meant:

con.FillCustomers(cboCountry.Text)

Note that later on in cboCountry_SelectedIndexChanged even he uses
Me.FillDataSet(dsCustomers1, cboCountry.Text)

which might the source for a cut and paste error.

This is a very old text that seems to contain a large number of typos.

It looks like you need to take the "Me" out of it.

Andrew

Hi Andrew,

Thanks !! I've tried that but I now get a different error message:-
Too many arguments to 'Public Function FillCustomersDataSet() as
dsCustomers'
Any ideas ?
 
For the second error, you need to go back to the definition of the
FillCustomersDataSet method for the Component1 class to see the argumentsit
requires. I can't find any such member.  From the comments following the
example, it is apparent that he actually meant FillDataSet. However, the
only methods he has defined for Component1 are FillCustomers (a function)
and UpdateCustomers. FillCustomers defines the ds to be used as Customers,
so I don't believe the call would require the dataset name to be passed.
Therefore, it looks like he meant:

con.FillCustomers(cboCountry.Text)

Note that later on in cboCountry_SelectedIndexChanged even he uses
Me.FillDataSet(dsCustomers1, cboCountry.Text)

which might the source for a cut and paste error.

This is a very old text that seems to contain a large number of typos.






Hi Andrew,

Thanks !! I've tried that but I now get a different error message:-
Too many arguments to 'Public Function FillCustomersDataSet() as
dsCustomers'
Any ideas ?- Hide quoted text -

- Show quoted text -

Thanks James,

That's sorted all the error messages appearing!!!
I must be missing some code somewhere though as I can't get any info
to appear in any of the boxes !!!
I'll must try harder !!!!

Thanks for all your help.

Paul
 
Thanks James,

That's sorted all the error messages appearing!!!
I must be missing some code somewhere though as I can't get any info
to appear in any of the boxes !!!
I'll must try harder !!!!

Thanks for all your help.

Paul- Hide quoted text -

- Show quoted text -

I've amended my code to :-

Private Sub cboCountry_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
cboCountry.SelectedIndexChanged
DsCustomers1.Clear()

OleDbDataAdapter1.SelectCommand.Parameters.Item("Country").Value =
cboCountry.SelectedValue
Try
Me.OleDbDataAdapter1.Fill(DsCustomers1, "Country")
Catch fillException As System.Exception
MsgBox("Caught exception: " & fillException.Message)

End Try


PositionIndicator()
End Sub

But I'm now getting this error :-

Pararmeter ?_1 has no default value

Could anyone point me in the right direction as to what I've got
wrong.
Thanks
 
What are the command parameters (OleDbDataAdapter1.SelectCommand.Parameters)
when the error occurs?

Thanks James,

That's sorted all the error messages appearing!!!
I must be missing some code somewhere though as I can't get any info
to appear in any of the boxes !!!
I'll must try harder !!!!

Thanks for all your help.

Paul- Hide quoted text -

- Show quoted text -

I've amended my code to :-

Private Sub cboCountry_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
cboCountry.SelectedIndexChanged
DsCustomers1.Clear()

OleDbDataAdapter1.SelectCommand.Parameters.Item("Country").Value =
cboCountry.SelectedValue
Try
Me.OleDbDataAdapter1.Fill(DsCustomers1, "Country")
Catch fillException As System.Exception
MsgBox("Caught exception: " & fillException.Message)

End Try


PositionIndicator()
End Sub

But I'm now getting this error :-

Pararmeter ?_1 has no default value

Could anyone point me in the right direction as to what I've got
wrong.
Thanks
 
Back
Top