473,473 Members | 1,994 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

ASP.Net and Data Adapters

When adding a SQL Data Adapter to a page, is possible to configure it use a
connection string in code?
As I have found it regenerates the code each time and of the adapters are
modified and does not allow the generate dataset option to be used.
Nov 18 '05 #1
3 1221
Unfortunately, you will have to keep reconnecting the Adapter if you use the
built in Drag and Drop stuff in the IDE. You can edit the connection string,
but the code is regenerated each time you muck with it. I tend to shy away
from drag-and-drop for this reason.
---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************

"Robin" wrote:
When adding a SQL Data Adapter to a page, is possible to configure it use a
connection string in code?
As I have found it regenerates the code each time and of the adapters are
modified and does not allow the generate dataset option to be used.

Nov 18 '05 #2
How much coding is required? Are there any resource explaining how to create
data adapters (plus other required data objects) just in code?

"Cowboy (Gregory A. Beamer) - MVP" <No************@comcast.netNoSpamM> wrote
in message news:7F**********************************@microsof t.com...
Unfortunately, you will have to keep reconnecting the Adapter if you use the built in Drag and Drop stuff in the IDE. You can edit the connection string, but the code is regenerated each time you muck with it. I tend to shy away
from drag-and-drop for this reason.
---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************

"Robin" wrote:
When adding a SQL Data Adapter to a page, is possible to configure it use a connection string in code?
As I have found it regenerates the code each time and of the adapters are modified and does not allow the generate dataset option to be used.

Nov 18 '05 #3
It's not terribly difficult - here's a sample of how I (roughly) do
this. I actually have a class that handles all of my DB stuff for me,
but here's an approximation.

string conn = "<APPROPRIATE CONNECTION STRING>";
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "<STORED PROC NAME>";
cmd.CommandType = CommandType.StoredProcedure;

cmd.Connection = new SqlConnection(conn);

try
{
SqlDataAdapter sda = new SqlDataAdapter(cmd);
sda.SelectCommand.Connection = cmd.Connection;

DataSet _dset = new DataSet();

// Automatically opens DB, gets the information, then closes it
sda.Fill(_dset);
}

// Send an error if something went wrong.
catch (Exception ex)
{
emailErrorMsg(ex.Message);
}
Robin wrote:
How much coding is required? Are there any resource explaining how to
create data adapters (plus other required data objects) just in code?

"Cowboy (Gregory A. Beamer) - MVP"
<No************@comcast.netNoSpamM> wrote in message
news:7F**********************************@microsof t.com...
Unfortunately, you will have to keep reconnecting the Adapter if
you use

the
built in Drag and Drop stuff in the IDE. You can edit the connection

string,
but the code is regenerated each time you muck with it. I tend to
shy away from drag-and-drop for this reason.
---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************

"Robin" wrote:
When adding a SQL Data Adapter to a page, is possible to
configure it use a connection string in code?
As I have found it regenerates the code each time and of the
adapters are modified and does not allow the generate dataset option to be
used.


Nov 18 '05 #4

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

Similar topics

1
by: Bob T | last post by:
Hi, I have been using SQLDataAdapters and Datasets in my project. I have a goal to simplify the project. Each data adapter has a corresponding dataset it retrieves values into. Even though...
5
by: Kevin C | last post by:
I was curious to know what some developers out in the industry are doing when it comes to exposing Data access logic, specifically persistence. This is assuming that your not using an O/R framework...
5
by: amanatio | last post by:
I have a huge form with many data bound controls on it and 34 tables in database (and of course 34 data adapters and 34 datasets). The form is extremely slow to design (huge delay when I go to code...
2
by: Mervin Williams | last post by:
I am using Infragistics UltraWebTab (a tab folder control for ASP.NET). My tab folder control will include five tab pages with a separate web form on each, and these web forms will share data. ...
5
by: Rick | last post by:
The data adapter wizard allows you to add more than one table, but that doesn't seem to work right when setting up a dataset. Some of the documentation I have read states that only one table...
0
by: dimpy | last post by:
Hi everyone, I am using some big size data adapters to fill datasets to be sent to a web service. Now every time i get an error in datatype or constraints violations while filling the dataset, I...
2
by: Paul Craig | last post by:
Hi everyone, I have recently upgraded several of my projects from Visual Studio 2003 to 2005 and everything went across quite smoothly. The main problem that I am having is I have used SQL Data...
1
by: Justin | last post by:
We decided to upgrade to 2005 and upgrade our components. After fixing a few odds and end the upgrade was complete and our project was working fine. We didn't run into problems until we needed to...
12
by: Randy | last post by:
Hi, Trying to pass along a table row delete to the datasource, but I'm crashing. Here is the code: Private Sub btnDeleteIngr_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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?

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.