how can I pass parameters from a class to a datagridview (in two layers) This is for a filter

'This is part of my class

PublicSub Find_Customers(ByVal nameAsString,ByVal dataAs System.Windows.Forms.DataGridView)

Dim StrSQLAsString

Dim mvarNameCustAsString

Dim daAs OleDb.OleDbDataAdapter

cnMat.Open()

mvarNameCust = name

StrSQL ="select * from Customers " &"where Name like '" & mvarNameCust &"%'"

da =New OleDb.OleDbDataAdapter(StrSQL, cnMat)

Dim dsAs DataSet =New DataSet()

*****Dim dt as DataTable = New DataTable()

******da.fill(dt)

da.Fill(ds)

data.DataSource = ds

******data.DataSource = dt

EndSub

'This is part of my windows.form.datagridview

PrivateSub txtCustomers_TextChanged(ByVal senderAs System.Object,ByVal eAs System.EventArgs)Handles txtCustomers.TextChanged

cust =New cCustomers

cust.Find_Customers(txtCustomers.Text, dgvCustomers)

EndSub

******Why this works with DataTable, but not with DataSet?

The problem is that I can receive data in dgvCustomers (datagridview). Any help would be appreciated.

[3481 byte] By [troublehenry] at [2007-12-22]
# 1

Hi,

I have noticed some few things in your code that will definitely be the root of your problems.

First thing is that within your class member function Find_CustomersFind_Customers, you commentend out loading your dataset by using the fill method of the dataAdaptor. So unless you undo this your dataset will be empty which means there will be nothing to pass to the datasource property of the datagrid control.Secondly you also commented out the databinding method of the datagrid, this is also needed.

I Hope this helps.

buddhie1 at 2007-8-30 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...

.NET Development

Site Classified