473,698 Members | 2,747 Online
Bytes | Software Development & Data Engineering Community
+ 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:SqlDataSou rce ID="BoardTypes " runat="server" ConnectionStrin g='<%$
ConnectionStrin gs:ConnectionSt ring %>'
SelectCommand=" SELECT BoardTypes.Boar dTypeId,
BoardTypes.Boar dTypeName, BoardTypes.Boar dTypeDescriptio n,
BoardTypes.Vali dityEndDate, BoardTypes.Vali dityStartDate,
OrganizationUni t.Name AS OrganizationalU nitName FROM BoardTypes INNER
JOIN OrganizationUni t ON OrganizationUni t.Id =
BoardTypes.Orga nizationalUnitI d WHERE (BoardTypes.IsC ancelled =
@IsCancelled)"
InsertCommand=" INSERT INTO BoardTypes(Boar dTypeName,
BoardTypeDescri ption, ValidityStartDa te, ValidityEndDate ,
OrganizationalU nitId, IsCancelled) VALUES (@BoardTypeName ,
@BoardTypeDescr iption, @ValidityStartD ate, @ValidityEndDat e,
@Organizational UnitId, 0)">
<SelectParamete rs>
<asp:Paramete r DefaultValue="f alse" Name="IsCancell ed"
Type="Boolean" />
</SelectParameter s>
<InsertParamete rs>
<asp:Paramete r Name="BoardType Name" Type="string" />
<asp:Paramete r Name="BoardType Description" Type="string"/>
<asp:Paramete r Name="ValidityS tartDate" Type="datetime" />
<asp:Paramete r Name="ValidityE ndDate" Type="datetime"/>
<asp:Paramete r Name="Organizat ionalUnitId" Type="string"/>
</InsertParameter s>
</asp:SqlDataSour ce>

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 programmaticall y.

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 InsertParameter s.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 1007

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

Similar topics

5
4476
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 ControlParameter <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:XYZ %>"
3
6799
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 a certain value? If the value comes from a control, form, querystring etc. then it's easily done declaratively. But how to do it in code. Have tried for hours. I will be grateful for all help! --
3
12730
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 on how to handle different tasks programmatically such as selects, updates, sorting of data etc. in code behind if I prefer to set all Gridview and Sqldatasource properties etc. in code behind rather than in the aspx file.
4
2339
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 SqlDataSource. What are the trade-offs between the AccessDataSource and SqlDataSource? Also, I am confused about the connection state. What are the rules of thumb for maintaining a db connection open vs closing it?
4
4614
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
4271
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 database from Access to SQL Server. So I go in to the SQLDataSource and modify it to connect to the SQL Server database. No problem. However, the DetailsView control does not seem to pick up the changes. When I click on the little shortcut menu (not...
2
2463
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 Provinces. The table contains 3 fields : LanguageID ProvinceID
0
850
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 configured it to retrieve
0
1166
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" runat="server" ConnectionString="<%$ ConnectionStrings:MyConnectionString%>" ProviderName="<%$ ConnectionStrings:MyConnectionString.ProviderName %>" SelectCommand="SELECT , FROM " DeleteCommand="DELETE FROM ContactInfo WHERE DocUNID
0
8611
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9170
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9031
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7741
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6531
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5867
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4372
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3052
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 we have to send another system
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.