Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TableAdapter Question 1

Status
Not open for further replies.

PsychoCoder

Programmer
May 31, 2006
140
US
I am working on creating a new DataSet (.xsd) for my web application. Ive created the DataTable, when I went to create the TableAdapter (using the TableAdapter Configuration Wizard) I select my ConnectionString, then choose "Use Stored Procedures" then it takes me to the screen to select my insert, update and delete procedures.

I select my Delete procedure then on the right side of the popup it asks you to select your columns for the parameters (I assume this is selecting fields from the DataTable Ive created) but there are no fields in the dropdown list. How do I get the fields from my datatable into this so I can finish the TableAdapter?

Anyone have any ideas?

Senior Qik III, ASP.Net, VB.Net ,SQL Programmer

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
** Do NOT feed Code Gremlins after midnight **
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
jbenson001,

I am actually using VS2005 (sorry I forgot to mention that)

Senior Qik III, ASP.Net, VB.Net ,SQL Programmer

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"In the new millennium there will be two kinds of business; those on the net and those out of business"

~ Bill Gates ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
Where is your datatable created? In the code behind? As far as I can see, the parameters can be mapped to columns returned in the select portion of the tableadapter.
 
jbenson001,

I right clicked on the App_Code project and selected "Add New Item", when the dialog opened I selected DataSet and went from there. First I added the DataTable then went to add the TableAdapter and thats where I ran into problems. Any ideas?

Senior Qik III, ASP.Net, VB.Net ,SQL Programmer

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"In the new millennium there will be two kinds of business; those on the net and those out of business"

~ Bill Gates ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
The wizard starts off by asking you to build a query or select stored procedures.
I tried creating a datatable then using the wizard, but I have found only that the parameters for INsert, Update or delete can only be mapped to columns returned by the select statement.
 
jbenson001,

Well in my Select statement I am returning all rows (by name not using "*") and it still shows no rows for me to map my TableAdapter to.

Senior Qik III, ASP.Net, VB.Net ,SQL Programmer

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"In the new millennium there will be two kinds of business; those on the net and those out of business"

~ Bill Gates ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
jbenson001,

Thanks for the advice, Ive fixed the problem.

Senior Qik III, ASP.Net, VB.Net ,SQL Programmer

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"In the new millennium there will be two kinds of business; those on the net and those out of business"

~ Bill Gates ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
jbenson001,

Since I had not used this feature before I did some reading on it. I dragged the SPROC I created for the SELECT command onto the designer view and that created my DataTable with the correct columns, it then opened the Connection Wizard and walked me through creating the TableAdapter. Now Im trying to find some articles on using this DataSet in a class file, since Ive not used a DataSet like this before. Any ideas?

Senior Qik III, ASP.Net, VB.Net ,SQL Programmer

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"In the new millennium there will be two kinds of business; those on the net and those out of business"

~ Bill Gates ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
Cool way of getting it to work, I will keep this in mind. What exactly are you trying to do now?
 
jbenson001,

I am creating a class file that basically talks with a database table. We are building a fairly (well more like extremely) large web application and wanted a class file to communicate directly with a specific table, to retrieve data, insert data, delete data so all we have to do is call the methods of this class file to do complex data manipulation.

Senior Qik III, ASP.Net, VB.Net ,SQL Programmer

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"In the new millennium there will be two kinds of business; those on the net and those out of business"

~ Bill Gates ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
So are you trying to figure out how to call the SPs on the dataset table adapter?
 
Actually Im trying to figure out how to use the Fill and Get methods of the DataSet I created (and also the delete SP in the DataSet).

Senior Qik III, ASP.Net, VB.Net ,SQL Programmer

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"In the new millennium there will be two kinds of business; those on the net and those out of business"

~ Bill Gates ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
Dim ds As New DataSet1.GetYourDataTableName
Dim tb As New DataSet1TableAdapters.YourDataTableNameTableAdapter
tb.Fill(ds)

Response.Write(ds.Rows.Count)
 
jbenson001,

But Im wanting to wrap this into a class file that does all that for me so all I have to do is something like:

MyDataGrid.DataSource = airItin.GetAirItin(rec_loc,segment)

Or something to that affect.

Senior Qik III, ASP.Net, VB.Net ,SQL Programmer

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"In the new millennium there will be two kinds of business; those on the net and those out of business"

~ Bill Gates ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
jbenson001,

Now I know I'm going to sound like a n00b but I'm really not. I'm a little confused, how can I use the code you used in my class file since there isnt a DataGrid, Repeater, GridView or any other bindable object, in the class how can I use tb.Fill(ds) without getting an error? Heres what I have, am I on the right track?:

Code:
Public Shared Function GetAirItin() As DataTable
   Dim Air As DataTable
   Air = airItin.GetFlightAirItin(sRecLoc, sSegment)

   airItin.FillFlightAirItin(Air, sRecLoc, sSegment)

   Return Air
End Function

Keep in mnd that at the top I have
Code:
Imports airItinTableAdapters

Then a global declaration at the top of the page:
Code:
Private Shared airItin As New flightAirItinTableAdapter

AM I even on the right track here or am I out in left field?

Senior Qik III, ASP.Net, VB.Net ,SQL Programmer

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"In the new millennium there will be two kinds of business; those on the net and those out of business"

~ Bill Gates ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
YOu are returning a datatable, which is all you want to do. Then bind that returned datatable to the grid ... or whatever:

dim dt as new datatable
dt = GetAirItin()

GridView1.datasource = dt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top