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
Solved

data access component - project doesn't access method correctly

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

860 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