?
Solved

data access component - project doesn't access method correctly

Posted on 2004-09-14
3
Medium Priority
?
189 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 250 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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month10 days, 23 hours left to enroll

770 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