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

Home Posts Topics Members FAQ

SqlDataSource and programatic access?

I've the following scenario, a web page that dispaly a GridView using
SqlDataSource define thus:

<asp:SqlDataSource ID="BoardTypes" runat="server" ConnectionString='<%$
ConnectionStrings:ConnectionString %>'
SelectCommand="SELECT BoardTypes.BoardTypeId,
BoardTypes.BoardTypeName, BoardTypes.BoardTypeDescription,
BoardTypes.ValidityEndDate, BoardTypes.ValidityStartDate,
OrganizationUnit.Name AS OrganizationalUnitName FROM BoardTypes INNER
JOIN OrganizationUnit ON OrganizationUnit.Id =
BoardTypes.OrganizationalUnitId WHERE (BoardTypes.IsCancelled =
@IsCancelled)"
InsertCommand="INSERT INTO BoardTypes(BoardTypeName,
BoardTypeDescription, ValidityStartDate, ValidityEndDate,
OrganizationalUnitId, IsCancelled) VALUES (@BoardTypeName,
@BoardTypeDescription, @ValidityStartDate, @ValidityEndDate,
@OrganizationalUnitId, 0)">
<SelectParameters>
<asp:Parameter DefaultValue="false" Name="IsCancelled"
Type="Boolean" />
</SelectParameters>
<InsertParameters>
<asp:Parameter Name="BoardTypeName" Type="string" />
<asp:Parameter Name="BoardTypeDescription" Type="string"/>
<asp:Parameter Name="ValidityStartDate" Type="datetime" />
<asp:Parameter Name="ValidityEndDate" Type="datetime"/>
<asp:Parameter Name="OrganizationalUnitId" Type="string"/>
</InsertParameters>
</asp:SqlDataSource>

I've a form that collects information about a new row and then post it
to the server. What I want to do is to take the values from the form
plus several other values that I get elsewhere, and insert them to the
database programmatically.

It's a dumb question, but I googled and looked in the help, and I can't
find the way to do it.

How do I pass the correct parameters? I tried InsertParameters.Add(),
but they already exist.
Another question:
Is it possible to create a page/file where I will declare all the data
sources? My goal is to be able to reuse a data source on several
classes, I can't see an immediate way to do it, though.

Nov 19 '05 #1
0 995

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

Similar topics

5
by: Martin Bischoff | last post by:
Hi, is it possible to modify the values of a SqlDataSource's select parameters in the code behind before the select command is executed? Example: I have an SqlDataSource with a...
3
by: Kees de Winter | last post by:
Hi, I am trying to set a parameter in the SELECT statement of a SqlDataSource, in the Page_Load event where the intended value for the parameter is calculated. But how can I set the parameter to...
3
by: Dorte | last post by:
Hi, Could someone help me with a couple of links to SqlDatasource documentation on how to use the Gridview and SqlDatasource components in code behind? Basically I'm missing some documentation...
4
by: msch-prv | last post by:
I use an Access db in my application. So far I have been exclusively working wtih the AccessDataSource controls to hook up to the db. I know that Access db connections can also be established with...
4
by: Mike | last post by:
Is there any difference in performance between a SqlDataSource and an ObjectDataSource - assuming they are being deployed to perform the same task against a SQL Server database? Mike
1
by: Corey B | last post by:
I have a page with a DetailsView control and a SQLDataSource control. The SQLDataSource control is connected to an Access database. Everything works fine. Now I want to change the back end...
2
by: Brad Isaacs | last post by:
Good evening friends, I have added a Drop Down List box control to my web form. I am using the web.config connection string to access my SQL Server 2000 db. Inside that db I have a table named...
0
by: Brad Isaacs | last post by:
Good evening friends, I have added a Drop Down List box control to my web form. The table contains 3 fields : LanguageID ProvinceID Province I have also added a SqlDataSource object and...
0
by: danielhamd | last post by:
I am converting a website that uses an Access Database to SQL Server. On one particular SqlDataSource I am having a lot of trouble. Here is the original: <asp:SqlDataSource ID="SqlDataSource1"...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
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 ...

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.