Solved

data access component - project doesn't access method correctly

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

762 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now