473,473 Members | 2,114 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

vs2005 datasources

If I create a datasource after dragging a GridView onto an aspx page it puts
my sql in the .aspx file. SQL in the aspx file is just wrong - it's like
going back to asp where we had code and sql in the asp file.

So I figured out how to create a TableAdapter:Dataset and now I have an .xsd
in my App_code folder. I drag a GridView onto an aspx page and now I want
to connect it to the dataset (so I won't have sql in my aspx file) but I
can't seem to do it.

Is there a way to do it?

Thanks for any help,
T
Jan 3 '06 #1
9 1450
On Mon, 2 Jan 2006 16:16:39 -0800, "T. Wong"
<tw***@nospammeexcite.com> wrote:
If I create a datasource after dragging a GridView onto an aspx page it puts
my sql in the .aspx file. SQL in the aspx file is just wrong - it's like
going back to asp where we had code and sql in the asp file.

So I figured out how to create a TableAdapter:Dataset and now I have an .xsd
in my App_code folder. I drag a GridView onto an aspx page and now I want
to connect it to the dataset (so I won't have sql in my aspx file) but I
can't seem to do it.

Is there a way to do it?

Thanks for any help,
T


Create a new class in your App_Code folder and use it to create
methods that return DataSets from your DataSet that you created.

In your web pages call that new class to get the DataSets, etc. you
want to bind to.
Otis Mukinfus
http://www.otismukinfus.com
http://www.tomchilders.com
Jan 3 '06 #2
Yes, I know I can do that and it's probably a pretty good practice -
particularly for large complex apps. But.....

VS.NET 2005 has taken away our ability to bind to a dataset at desing time,
no?

It seems to me that TableAdapters:DataSets are the way to go and not this
silly datasource that puts SQL in our pages and can't be shared between
pages.

I'm trying to find the "Best Practice" going forward.
Thanks for your response,
T

"Otis Mukinfus" <ph***@emailaddress.com> wrote in message
news:he********************************@4ax.com...
On Mon, 2 Jan 2006 16:16:39 -0800, "T. Wong"
<tw***@nospammeexcite.com> wrote:
If I create a datasource after dragging a GridView onto an aspx page it
puts
my sql in the .aspx file. SQL in the aspx file is just wrong - it's like
going back to asp where we had code and sql in the asp file.

So I figured out how to create a TableAdapter:Dataset and now I have an
.xsd
in my App_code folder. I drag a GridView onto an aspx page and now I want
to connect it to the dataset (so I won't have sql in my aspx file) but I
can't seem to do it.

Is there a way to do it?

Thanks for any help,
T


Create a new class in your App_Code folder and use it to create
methods that return DataSets from your DataSet that you created.

In your web pages call that new class to get the DataSets, etc. you
want to bind to.
Otis Mukinfus
http://www.otismukinfus.com
http://www.tomchilders.com

Jan 3 '06 #3
No..

Just add a SQLDataSource...
Configure it how you want...

Then to access the info in code:

Dim Dt as Data.DataTable = CType(SqlDataSource1.Select(New
DataSourceSelectArguments), Data.DataView).Table
Jan 3 '06 #4
any idea how I can reference that dataset from my class?

"Otis Mukinfus" <ph***@emailaddress.com> wrote in message
news:he********************************@4ax.com...
On Mon, 2 Jan 2006 16:16:39 -0800, "T. Wong"
<tw***@nospammeexcite.com> wrote:
If I create a datasource after dragging a GridView onto an aspx page it
puts
my sql in the .aspx file. SQL in the aspx file is just wrong - it's like
going back to asp where we had code and sql in the asp file.

So I figured out how to create a TableAdapter:Dataset and now I have an
.xsd
in my App_code folder. I drag a GridView onto an aspx page and now I want
to connect it to the dataset (so I won't have sql in my aspx file) but I
can't seem to do it.

Is there a way to do it?

Thanks for any help,
T


Create a new class in your App_Code folder and use it to create
methods that return DataSets from your DataSet that you created.

In your web pages call that new class to get the DataSets, etc. you
want to bind to.
Otis Mukinfus
http://www.otismukinfus.com
http://www.tomchilders.com

Jan 4 '06 #5
But, I don't want to use an asp Datasource because:
1. it can't be shared between pages
2. it puts sql in my aspx file and that's just wrong

I want use a TableAdapter:Dataset that I have put in my App_code folder from
a class in that same folder. I would then call methods in that class from
aspx pages and do a databind to my GridView, or whatever control, in my aspx
codebehind file. That way I can share datasets in my pages and I have no
crapy sql code in my aspx file.

But I can't find a way to reference the TableAdapter:Dataset from my class.

T.
"Matthew" <Ma*****@nospam.net> wrote in message
news:43**************@nospam.net...
No..

Just add a SQLDataSource...
Configure it how you want...

Then to access the info in code:

Dim Dt as Data.DataTable = CType(SqlDataSource1.Select(New
DataSourceSelectArguments), Data.DataView).Table

Jan 4 '06 #6
On Tue, 3 Jan 2006 17:58:28 -0800, "T. Wong"
<tw***@nospammeexcite.com> wrote:
But, I don't want to use an asp Datasource because:
1. it can't be shared between pages
2. it puts sql in my aspx file and that's just wrong

I want use a TableAdapter:Dataset that I have put in my App_code folder from
a class in that same folder. I would then call methods in that class from
aspx pages and do a databind to my GridView, or whatever control, in my aspx
codebehind file. That way I can share datasets in my pages and I have no
crapy sql code in my aspx file.

But I can't find a way to reference the TableAdapter:Dataset from my class.

[snip]

I did this just the other day. look in the code generated when to
created you xsd file (YourDataSet.Designer.cs) and search for
TableAdapter you will find a namespace named
YourDataSetTableAdapters. Add a using statement to your class (using
YourDataSetTableAdapters;) and you will be able to call the table
adapters from your code.

Here's an example of code from a test I did for this:

using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using TestConsole.N5GEDataSetTableAdapters;

namespace TestConsole
{
class Program
{
static void Main(string[] args)
{
USCitiesTableAdapter ta = new USCitiesTableAdapter();
N5GEDataSet ds = new N5GEDataSet();

ta.Fill(ds.USCities);

DataRow [] cities =
ds.USCities.select("Distinct city = 'arlington'", "City, state
ASC");
}
}
}

Otis Mukinfus
http://www.otismukinfus.com
http://www.tomchilders.com
Jan 5 '06 #7
On Wed, 04 Jan 2006 20:06:37 -0600, Otis Mukinfus
<ph***@emailaddress.com> wrote:

Take DISTINCT out of the sample and it will work....
On Tue, 3 Jan 2006 17:58:28 -0800, "T. Wong"
<tw***@nospammeexcite.com> wrote:
But, I don't want to use an asp Datasource because:
1. it can't be shared between pages
2. it puts sql in my aspx file and that's just wrong

I want use a TableAdapter:Dataset that I have put in my App_code folder from
a class in that same folder. I would then call methods in that class from
aspx pages and do a databind to my GridView, or whatever control, in my aspx
codebehind file. That way I can share datasets in my pages and I have no
crapy sql code in my aspx file.

But I can't find a way to reference the TableAdapter:Dataset from my class.

[snip]

I did this just the other day. look in the code generated when to
created you xsd file (YourDataSet.Designer.cs) and search for
TableAdapter you will find a namespace named
YourDataSetTableAdapters. Add a using statement to your class (using
YourDataSetTableAdapters;) and you will be able to call the table
adapters from your code.

Here's an example of code from a test I did for this:

using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using TestConsole.N5GEDataSetTableAdapters;

namespace TestConsole
{
class Program
{
static void Main(string[] args)
{
USCitiesTableAdapter ta = new USCitiesTableAdapter();
N5GEDataSet ds = new N5GEDataSet();

ta.Fill(ds.USCities);

DataRow [] cities =
ds.USCities.select("Distinct city = 'arlington'", "City, state
ASC");
}
}
}

Otis Mukinfus
http://www.otismukinfus.com
http://www.tomchilders.com


Otis Mukinfus
http://www.otismukinfus.com
http://www.tomchilders.com
Jan 5 '06 #8
Can you not use an ObjectDataSource?
With you gridview use an objectdatasource rather than a SqlDataSource,
and bind the ObjectDataSource to you DataSet. This will keep your Sql
off the page, and you'l be ale to use you dataset.

Hope this helps

Eric

On Mon, 2 Jan 2006 16:16:39 -0800, "T. Wong"
<tw***@nospammeexcite.com> wrote:
If I create a datasource after dragging a GridView onto an aspx page it puts
my sql in the .aspx file. SQL in the aspx file is just wrong - it's like
going back to asp where we had code and sql in the asp file.

So I figured out how to create a TableAdapter:Dataset and now I have an .xsd
in my App_code folder. I drag a GridView onto an aspx page and now I want
to connect it to the dataset (so I won't have sql in my aspx file) but I
can't seem to do it.

Is there a way to do it?

Thanks for any help,
T


Jan 5 '06 #9
Can you not use an ObjectDataSource?
With you gridview use an ObjectDataSource rather than a SqlDataSource, and
bind the ObjectDataSource to your DataSet. This will keep your Sql off the
page, and you'l be ale to use you dataset.

Hope this helps

Eric

"T. Wong" wrote:
If I create a datasource after dragging a GridView onto an aspx page it puts
my sql in the .aspx file. SQL in the aspx file is just wrong - it's like
going back to asp where we had code and sql in the asp file.

So I figured out how to create a TableAdapter:Dataset and now I have an .xsd
in my App_code folder. I drag a GridView onto an aspx page and now I want
to connect it to the dataset (so I won't have sql in my aspx file) but I
can't seem to do it.

Is there a way to do it?

Thanks for any help,
T

Jan 5 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Greg | last post by:
Anyone having issues with their object datasources appearing and vanishing from the datasource browser? I create an object for binding as a datasource in my App_Code folder, compile my web...
3
by: dbuchanan | last post by:
Here are pertinent parts of my solution structure \\ Solution 'QMS_01 -QmsDataLayer ---My Project ---app.config ---DataSet1.xsd -QmsUI ---My Project ------DataSources (folder)
9
by: GaryDean | last post by:
We have been noticing that questions on vs.2005/2.0 don't appear to get much in answers so I'm reposting some questions posted by some of the programmers here in our organization that never got...
1
by: Bob | last post by:
During a form's development I noticed that when I changed bound dataset defintions with the dataset designer (for instance adding a column to one), when I come back and look at the form the...
0
by: Owen Richardson | last post by:
I have a page that displays a news article in a form view feeding off a datasource that just picks up the id from a query string. I want to add functionality for related links - so i created a...
1
by: Magnus | last post by:
I have a set of typed datasets that are tied to a database on a mssql2005 server. They are naturally displayed and available in the DataSources window. Now I want to rename the database, but when I...
3
by: jobs | last post by:
I've got a gridview that does not have a datasourceid assigned in the markup. I'd like to switch between two datasources in the codebehind. when I do switch, I first reset the the...
19
by: cpnet | last post by:
I'm using VS2005, C#, ASP.NET 2.0. I'm trying to create a report using SQL Reporting Services (to be used in local mode so I don't have to deal with SQL Server). When I create a new report in my...
0
by: =?Utf-8?B?Unlhbg==?= | last post by:
I have the following code which compiles fine but the data set (ds) returns 0 count and the rptViewer1 is blank. If I change the name of the rdlc file (rep.ReportPath = "Customer.rdlc";) to...
0
by: =?Utf-8?B?Umljaw==?= | last post by:
The following code is diaplaying a blank report; how do I fix it? private void Form1_Load(object sender, EventArgs e) { LoadReport(); } public void LoadReport() {...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.