Solved

data access component - project doesn't access method correctly

Posted on 2004-09-14
3
187 Views
Last Modified: 2010-04-23
I made a component of several dataadapters and a dataset.  I also included a public method:

Public class cmpITdata
Public Sub LoadData(ByVal ds As DataSet)
        daVendors.Fill(Ds, "spSelVendors")
        daInvoices.Fill(Ds, "spSelInvoices")
        daBudCat.Fill(Ds, "spSelBudCat")
        daSubCat.Fill(Ds, "spSelSubCat")
        daPurchases.Fill(Ds, "spSelPurchases")
End Sub
End class

When I call the method in my project, I reference it as follows:

cmditdata.loaddata(dsbuddata)

I added a datagrid to the form and specified the datasource as dsbuddata, datamember as spselvendors, and the datakeyfield as vendorid.

In the pageload event I call the databind method on the datagrid (dgVendors.databind) (of course I do this after calling the LoadData procedure).

When I run the project, no data appears in the datagrid.  However, if, instead of calling the loaddata procedure, I do the following, it works:

cmdITdata.daVendors.fill(dsbuddata, "spselvndors")
dgVendors.databind

This is my first component so i'm sure I'm doing something wrong here!  Any help would be much appreciated.  Thanks!
0
Comment
Question by:tsbathe
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 10

Accepted Solution

by:
123654789987 earned 125 total points
ID: 12061609
What are spSelVendors?

1.  U can get data from a table in the database like this

Public Sub CreateSqlConnection() as Dataset
    Dim myConnection As New SqlConnection()
    myConnection.ConnectionString = "Persist Security Info=False;Integrated Security=SSPI;database=northwind;server=mySQLServer;Connect Timeout=30"
    myConnection.Open()
mycommand.connection = myConnection;
myCommand.CommandText = "SELECT * FROM Emp ORDER BY EmpNo"
    myCommand.CommandType = CommandType.Text
Dataset ds = ExecuteDataset(myCommand)
return ds;
End Sub

2. Then u have to fill dataAdapter

dataAdapater1.Fill(ds);

3. Datagrid1.Datasource = ds.Tables[0]; or
Datagris1.SetDataBinding(ds,"VendorId"); here VendorId is the datamember

See this example

http://www.c-sharpcorner.com/database/data_view_1.asp




0
 

Author Comment

by:tsbathe
ID: 12064027
spSelVendors is the name of the select statement of the data adapter daVendors, a stored procedure.  Tables in my dataset are listed as the names of the select statements of my data adapters.  I already have my sqlconnection setup in design mode....I just need to know how to correctly access a public method that is in a component...
0
 

Author Comment

by:tsbathe
ID: 12209995
I still need help with this issue, anyone have any ideas?
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question