Solved

data access component - project doesn't access method correctly

Posted on 2004-09-14
3
188 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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
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.

690 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