How To Retrive Single Data From Sqldatasource Control

Aug 19, 2006

hi,

i need to code for retrieving single data from sqldatasource control. i need the full set of coding

connecting
retrieving data in text box
editing data to the table
updating data to the table
deleting data to the table

i want to fetch "single field data"

any one who know the code please post reply or send it to my mail senthilonline_foryou@rediffmail.com

View 1 Replies


ADVERTISEMENT

How To Retrieve Data From A SQLDataSource Control

Jun 10, 2007

I have made a SQLDataSource control with the select command:
SELECT COUNT(*) AS 'Antall' FROM Utgivelse WHERE (medieID = @medieID)
I want to use the "Antall" result programmatically in C# code. I try the following statement:        IDataReader MyReader;
 
       MyReader = CType(SqlDataSource2.Select(DataSourceSelectArguments.Empty),IDataReader);
but it doesnot work. Can somebody help me how to get the data from th control ?
Tom

View 2 Replies View Related

SqlDataSource Control Error When Trying To Sort The Data

Feb 5, 2007

Hello:I forgot what to do in a case like this. I have a SqlDataSource control within a label and I want to allow auto sorting, but when I click on the sort link the page comes back with:The SqlDataSource control 'sqlViewIncompleteForms' does not have a naming container.  Ensure that the control is added to the page before calling DataBind.[HttpException (0x80004005): The SqlDataSource control 'sqlViewIncompleteForms' does not have a naming container.  Ensure that the control is added to the page before calling DataBind.]   System.Web.UI.WebControls.DataBoundControlHelper.FindControl(Control control, String controlID) +1590679   System.Web.UI.WebControls.ControlParameter.Evaluate(HttpContext context, Control control) +76   System.Web.UI.WebControls.Parameter.UpdateValue(HttpContext context, Control control) +46   System.Web.UI.WebControls.ParameterCollection.UpdateValues(HttpContext context, Control control) +103   System.Web.UI.WebControls.SqlDataSource.LoadCompleteEventHandler(Object sender, EventArgs e) +40   System.EventHandler.Invoke(Object sender, EventArgs e) +0   System.Web.UI.Page.OnLoadComplete(EventArgs e) +2010392   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1209How do I over come this? Do I have to use the find control method on page_load? Here is the code portion .vb<%  'Label which contains the default.aspx home content %><asp:Label ID="recip_home_display" runat="server" Visible="false">    <div align="center" class="HeaderSmall">Incomplete Recip Submissions</div>    <asp:GridView ID="RecipStatusGridView" runat="server" AutoGenerateColumns="False" BorderWidth="0px" DataKeyNames="queue_id"        DataSourceID="sqlViewIncompleteForms" AllowPaging="True" AllowSorting="True" CellPadding="2" CellSpacing="2" CssClass="TextSmall" HorizontalAlign="Center" Width="500px" Visible="False">        <Columns>            <asp:BoundField DataField="queue_id" HeaderText="Incomplete Listings" HtmlEncode="False"                InsertVisible="False" ReadOnly="True" SortExpression="queue_id">                <ControlStyle CssClass="LinkNormal" />                <ItemStyle HorizontalAlign="Center" />                <HeaderStyle HorizontalAlign="Center" />            </asp:BoundField>            <asp:BoundField DataField="form_type" HeaderText="Listing Type" SortExpression="form_type">                <ItemStyle HorizontalAlign="Center" />                <HeaderStyle HorizontalAlign="Center" />            </asp:BoundField>            <asp:BoundField DataField="listing_address" HeaderText="Listing Address" ReadOnly="True"                SortExpression="listing_address">                <ItemStyle HorizontalAlign="Center" />                <HeaderStyle HorizontalAlign="Center" />            </asp:BoundField>            <asp:BoundField DataField="last_modified_date" DataFormatString="{0:d}" HeaderText="Last Modified"                HtmlEncode="False" SortExpression="last_modified_date">                <ItemStyle HorizontalAlign="Center" />                <HeaderStyle HorizontalAlign="Center" />            </asp:BoundField>        </Columns>        <HeaderStyle BackColor="#5C6F8D" />        <AlternatingRowStyle BackColor="#e9eaf0" />    </asp:GridView>    <asp:SqlDataSource ID="sqlViewIncompleteForms" runat="server" ProviderName="System.Data.SqlClient" ConnectionString="<%$ Appsettings:connectionstring %>" SelectCommandType="StoredProcedure" SelectCommand="spGetIncompleteForms">    <SelectParameters>        <asp:ControlParameter ControlID="active_member_id" Name="AgentId" />    </SelectParameters></asp:SqlDataSource></asp:Label>

View 1 Replies View Related

How Do I Programmatically Inert Data Using A SqlDataSource Control?

May 19, 2007

I just want to insert a record into a table using a SqlDataSource control.  But I'm having a hard time finding examples that don't use data bound controlsI have this so far (I deleted the parts not related to the insert):<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:UserPolls %>"    InsertCommand="INSERT INTO [PollAnswers] ([PollId], [AnswerText], [AnswerCount]) VALUES (@PollId, @AnswerText, @AnswerCount)"    <InsertParameters>        <asp:Parameter Name="PollId" Type="Int32" />        <asp:Parameter Name="AnswerText" Type="String" />        <asp:Parameter Name="AnswerCount" Type="Int32" />    </InsertParameters> </asp:SqlDataSource> This is the data source for a gridview control I have on the page.  I could set up an SqlDataSource for this alone if I need to, but i don't know if it would help.  From what I could find, in the code behind I should haveSqlDataSource2.Insert()and SqlDataSource2  will grab the parameters and insert the record.  The problem is I need to set the Pollid (from a session variable) and AnswerText (from a text box) at run time.  Can I do this?Diane 

View 3 Replies View Related

How Do I Get Data Type Of Each Column In A Sqldatasource Control?

Sep 6, 2007

Let's say... the sqldatasource has 3 columns: TableKey(int), TableName(string) and StartDate(datetime) and i'm writing a method to return the data type based on the column name.. for example: GetDataType("StartDate") should return "datetime"...what should i do?

View 2 Replies View Related

Need Help Submitting Form Data To SQL 2005 Database Using SqlDataSource Control

Apr 18, 2006

I have a form setup, the code of which is listed below, and I would like to be able to submit the data that is entered in the form to a SQL 2005 standard database via the SqlDataSource control and a button. I'm just having trouble doing so because of the coding. Any help or suggestions would be greata s I've already read through the tutorials on this site and they don't go in depth very much. Thanks!
<%@ Page Language="VB" %>
<%@ Register Assembly="BasicFrame.WebControls.BasicDatePicker" Namespace="BasicFrame.WebControls"
TagPrefix="BDP" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<Script runat="server">
Private Sub InsertData(ByVal Source As Object, ByVal e As EventArgs)
SqlDataSource1.Insert()
End Sub
</Script>
 
 
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Weston E-Vault - New Customer Sign-Up Form</title>
</head>
<body>
<form id="form1" runat="server">
<div style="text-align: center">
&nbsp;<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Data Source=C26819_24561;Initial Catalog=ebackups;Integrated Security=True;User Instance=False" ProviderName="System.Data.SqlClient" InsertCommand="INSERT INTO backup_info(cust_name, cust_phone, cust_contact, cust_analyst, storage_plan, install_date, backup_data, backupexec_option, backup_program, cust_email) VALUES (@cust_name, @cust_phone, @cust_contact, @cust_analyst, @storage_plan, @install_date, @backup_data, @backupexec_option, @backup_program, @cust_email)">
<InsertParameters>
<asp:ControlParameter ControlID="DropDownList1" DefaultValue="" Name="@cust_name"
PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="TextBox1" Name="@cust_contact" PropertyName="Text" />
<asp:ControlParameter ControlID="TextBox2" Name="@cust_phone" PropertyName="Text" />
<asp:ControlParameter ControlID="DropDownList3" Name="@cust_analyst" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="BDPLite1" Name="@install_date" PropertyName="Controls" />
<asp:ControlParameter ControlID="TextBox3" Name="@cust_username" PropertyName="Text" />
<asp:ControlParameter ControlID="TextBox4" Name="@cust_password" PropertyName="Text" />
<asp:ControlParameter ControlID="DropDownList2" Name="@storage_plan" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="TextBox5" Name="@backup_data" PropertyName="Text" />
<asp:ControlParameter ControlID="RadioButtonList1" Name="@backupexec_option" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="TextBox6" Name="@backup_program" PropertyName="Text" />
<asp:ControlParameter ControlID="TextBox7" Name="@cust_email" PropertyName="Text" />
</InsertParameters>
</asp:SqlDataSource>
&nbsp;
<br />
<br />
<br />
<table>
<tr>
<td style="width: 100px">
<img src="/images/westonevault_logo.jpg" /></td>
<td style="width: 703px; text-align: right">
<asp:Button ID="Button1" runat="server" BackColor="White" BorderColor="Navy" BorderStyle="Solid"
BorderWidth="1px" Font-Names="verdana" Font-Size="Small" ForeColor="Navy" PostBackUrl="~/secure/tech_home.aspx"
Text="Back" /><span style="font-size: 8pt; color: #000099">&nbsp;</span></td>
</tr>
</table>
<br />
<br />
<img src="/images/div.jpg" style="font-size: 8pt; color: #000099" /><br />
<br />
<div style="text-align: center">
<table style="font-size: 8pt; width: 730px; color: #000099; font-family: Verdana">
<tr>
<td colspan="3" style="font-weight: bold; font-family: Verdana; text-align: left">
<span style="color: #000099">Customer Information<br />
</span>
<hr style="color: #000099" />
<span style="font-weight: normal; font-size: 8pt; color: #000099">Please enter all customer
data as accurately as possible. Any incorrect information on this form may result
in incorrect data being backed up, reports not reaching the customer or they may<span
style="font-size: 12pt"><strong> </strong><span style="font-size: 8pt">not receive the need</span></span>ed amount of disk
space.<br />
&nbsp;<br />
</span>
</td>
</tr>
<tr style="font-size: 8pt">
<td style="width: 174px; text-align: left">
<span style="font-family: Verdana"><span style="color: navy">Customer
Name:<br />
</span>
<asp:DropDownList ID="DropDownList1" runat="server" DataValueField="cust_name" Font-Names="Verdana"
Font-Size="X-Small" ForeColor="Navy" Width="178px">
<asp:ListItem Selected="True">Select Customer Name.....</asp:ListItem>
<asp:ListItem>Alaska Road Boring</asp:ListItem>
<asp:ListItem>Allen and Peterson</asp:ListItem>
<asp:ListItem>AK Guns</asp:ListItem>
<asp:ListItem>ATS Alaska</asp:ListItem>
<asp:ListItem>BC Contractors</asp:ListItem>
<asp:ListItem>Bek of Alaska</asp:ListItem>
<asp:ListItem>Brokentop Community Assoc.</asp:ListItem>
<asp:ListItem>COHRA</asp:ListItem>
<asp:ListItem>Crisis Pregnancy Center</asp:ListItem>
<asp:ListItem>Gaines and Co.</asp:ListItem>
<asp:ListItem Value="Gil Damond">Gil Damond</asp:ListItem>
<asp:ListItem>GMW Fire</asp:ListItem>
<asp:ListItem>Integrity Funding</asp:ListItem>
<asp:ListItem>La Pine Community Clinic</asp:ListItem>
<asp:ListItem>La Pine Fire District</asp:ListItem>
<asp:ListItem>Lumbermens Ins.</asp:ListItem>
<asp:ListItem>Murray</asp:ListItem>
<asp:ListItem>NEI</asp:ListItem>
<asp:ListItem>Northstar Center</asp:ListItem>
<asp:ListItem>Redi Electric</asp:ListItem>
<asp:ListItem>Robberson Ford</asp:ListItem>
<asp:ListItem>South Anchorage District Office</asp:ListItem>
<asp:ListItem>St. George Tanaq</asp:ListItem>
<asp:ListItem>Stinebaugh</asp:ListItem>
<asp:ListItem>THT Electric</asp:ListItem>
<asp:ListItem>Watterson</asp:ListItem>
<asp:ListItem>United Auto</asp:ListItem>
<asp:ListItem>Weston - ANC</asp:ListItem>
<asp:ListItem>Weston - BND</asp:ListItem>
<asp:ListItem></asp:ListItem>
</asp:DropDownList><br />
</span>
</td>
<td style="width: 187px; text-align: left">
<span style="font-family: Verdana"><span style="color: #000099">Customer
Contact:<br />
</span>
<asp:TextBox ID="TextBox1" runat="server" Font-Names="Verdana" Font-Size="X-Small"
Width="164px"></asp:TextBox><br />
</span>
</td>
<td style="width: 136px; text-align: left">
<span style="font-family: Verdana"><span style="color: #000099">Customer
Phone:<br />
</span>
<asp:TextBox ID="TextBox2" runat="server" Font-Names="verdana" Font-Size="X-Small"></asp:TextBox><br />
</span>
</td>
</tr>
<tr style="font-size: 8pt">
<td style="width: 174px; text-align: left">
<span style="font-family: Verdana"><span style="color: #000099">Customer
E-Vault Username:<br />
</span>
<asp:TextBox ID="TextBox3" runat="server" Font-Names="Verdana" Font-Size="X-Small"
Width="150px"></asp:TextBox><br />
</span>
</td>
<td style="width: 187px; text-align: left">
<span style="font-family: Verdana"><span style="color: #000099">Customer
E-Vault Password:<br />
</span>
<asp:TextBox ID="TextBox4" runat="server" Font-Names="Verdana" Font-Size="X-Small"
TextMode="Password" Width="150px"></asp:TextBox><br />
</span>
</td>
<td style="width: 136px; text-align: left">
<span style="font-family: Verdana"><span style="color: #000099">E-Vault
Storage Plan:<br />
</span>
<asp:DropDownList ID="DropDownList2" runat="server" DataValueField="storage_plan"
Font-Names="Verdana" Font-Size="X-Small" ForeColor="Navy">
<asp:ListItem Selected="True">Select Plan.....</asp:ListItem>
<asp:ListItem>0-300MB</asp:ListItem>
<asp:ListItem>300MB-2GB</asp:ListItem>
<asp:ListItem>2GB-4GB</asp:ListItem>
<asp:ListItem>4GB-6GB</asp:ListItem>
<asp:ListItem>6GB-8GB</asp:ListItem>
<asp:ListItem>8GB-15GB</asp:ListItem>
<asp:ListItem>15GB-25GB</asp:ListItem>
<asp:ListItem>25GB-35GB</asp:ListItem>
<asp:ListItem>35GB-50GB</asp:ListItem>
<asp:ListItem>50GB-100GB</asp:ListItem>
<asp:ListItem>100GB-200GB</asp:ListItem>
</asp:DropDownList><br />
</span>
</td>
</tr>
<tr style="font-size: 8pt">
<td style="width: 174px; text-align: left">
<span style="font-family: Verdana"><span style="color: #000099">Analyst:<br />
</span>
<asp:DropDownList ID="DropDownList3" runat="server" DataValueField="cust_analyst"
Font-Names="Verdana" Font-Size="X-Small" ForeColor="Navy" Width="162px">
<asp:ListItem>Select Analyst.....</asp:ListItem>
<asp:ListItem>Brock McFarlane</asp:ListItem>
<asp:ListItem>Cameron Farrally</asp:ListItem>
<asp:ListItem>Chad Huls</asp:ListItem>
<asp:ListItem>Eric Spinney</asp:ListItem>
<asp:ListItem>Greg Freeman</asp:ListItem>
<asp:ListItem>Harald Smit</asp:ListItem>
<asp:ListItem>Kevin Mark</asp:ListItem>
<asp:ListItem>Mark Anderson</asp:ListItem>
<asp:ListItem>Mike Murphy</asp:ListItem>
<asp:ListItem>Tim Elder</asp:ListItem>
</asp:DropDownList><br />
</span>
</td>
<td style="width: 187px; text-align: left">
<span style="font-family: Verdana"><span style="color: #000099">Today's
Date: (mm/dd/yyy)<br />
</span>
<bdp:bdplite id="BDPLite1" runat="server" borderstyle="None" cssclass="bdpLite" dateformat="ShortDate"
font-bold="False" font-names="verdana" font-size="X-Small" forecolor="Navy" selecteddate=""></bdp:bdplite>
</span>
</td>
<td style="width: 136px; text-align: left">
<br />
</td>
</tr>
<tr style="font-size: 8pt">
<td colspan="3">
</td>
</tr>
<tr style="font-size: 8pt">
<td colspan="3" style="text-align: left">
<span style="font-family: Verdana"><span style="color: #000099"><strong>
<br />
Backup Data<br />
<hr style="color: #000099" />
</strong><span>Please enter all directories and/or files and
folders the customer wishes to have backed up. Be thourough yet brief as this is
for historical and record keeping purposes.<br />
<br />
</span></span></span>
</td>
</tr>
<tr style="font-size: 8pt">
<td colspan="3" style="text-align: left">
<asp:TextBox ID="TextBox5" runat="server" ForeColor="#000000" Height="130px" MaxLength="200"
TextMode="MultiLine" Width="503px"></asp:TextBox><br />
</td>
</tr>
<tr style="font-size: 8pt">
<td style="width: 174px">
</td>
<td style="width: 187px">
</td>
<td style="width: 136px">
</td>
</tr>
<tr style="font-size: 8pt">
<td colspan="3" style="text-align: left">
<span style="font-family: Verdana"><span style="color: #000099"><strong>
<br />
BackupExec / NTBackup<br />
<hr style="color: #000099" />
</strong><span>Does the customer have another backup program
running that backs up their files to tape or another physical media.<br />
<br />
</span></span></span>
</td>
</tr>
<tr style="font-size: 8pt">
<td colspan="2" style="height: 41px; text-align: left">
<asp:RadioButtonList ID="RadioButtonList1" runat="server" Font-Names="Verdana" Font-Size="X-Small"
ForeColor="Navy" RepeatDirection="Horizontal" Width="127px">
<asp:ListItem Value="Yes">Yes</asp:ListItem>
<asp:ListItem Value="No">No</asp:ListItem>
</asp:RadioButtonList><span style="font-family: Verdana"><span style="color: #000099">If
"Yes", what program do they use?</span>
<asp:TextBox ID="TextBox6" runat="server" Font-Names="Verdana" Font-Size="X-Small"
Width="200px"></asp:TextBox><br />
</span>
</td>
<td style="width: 136px; height: 41px">
</td>
</tr>
<tr style="font-size: 8pt">
<td style="width: 174px">
</td>
<td style="width: 187px">
</td>
<td style="width: 136px">
</td>
</tr>
<tr style="font-size: 8pt">
<td colspan="3" style="text-align: left">
<span style="color: #000099"><span style="font-family: Verdana"><strong>
<br />
E-Mail Notifications<br />
<hr style="color: #000099" />
</strong><span>Does the customer wish to receive weekly reports
about their backups? (This includes what directories are being backed up, how much
storage space they have used on their plan and how much storage space is remaining).If
so enter their e-mail address below. If they don't want to receive notifications,
you can skip this section.<br />
<br />
</span></span></span>
</td>
</tr>
<tr style="font-size: 8pt">
<td style="width: 174px; text-align: left">
<asp:TextBox ID="TextBox7" runat="server" Font-Names="Verdana" Font-Size="XX-Small"
ForeColor="Navy" Width="201px"> N/A</asp:TextBox></td>
<td style="width: 187px">
</td>
<td style="width: 136px">
</td>
</tr>
<tr style="font-size: 8pt">
<td style="width: 174px">
</td>
<td style="width: 187px">
</td>
<td style="width: 136px">
</td>
</tr>
<tr style="font-size: 8pt">
<td style="width: 174px; height: 26px">
</td>
<td style="width: 187px; height: 26px; text-align: left">
<asp:Button ID="Button2" runat="server" BackColor="White" BorderColor="Navy" BorderStyle="Solid"
BorderWidth="1px" Font-Names="verdana" Font-Size="Small" OnClick="InsertData" Text="Submit Form" /></td>
<td style="width: 136px; height: 26px">
</td>
</tr>
</table>
&nbsp;&nbsp;</div>
<div style="text-align: center">
<img src="/images/div.jpg" /><br />
<br />
<span style="font-size: 7pt; font-family: Verdana">Copyright 2006 Weston Technology
Solutions </span>
</div>

</div>
</form>
</body>
</html>

View 3 Replies View Related

Problem Use Sqldatasource To Access Stored Procedure And Get Data Bind To Label Control

Aug 30, 2007

Hi every experts
I have a exist Stored Procedure in SQL 2005 Server, the stored procedure contain few output parameter, I have no problem to get result from output parameter to display using label control by using SqlCommand in Visual Studio 2003. Now new in Visual Studio 2005, I can't use sqlcommand wizard anymore, therefore I try to use the new sqldatasource control. When I Configure Datasource in Sqldatasource wizard, I assign select field using exist stored procedure, the wizard control return all parameter in the list with auto assign the direction type(input/ouput....), after that, whatever I try, I click on Test Query Button at last part, I always get error message The Query did not return any data table.
My Question is How can I setup sqldatasource to access Stored Procedure which contain output parameter, and after that How can I assign the output parameter value to bind to the label control's Text field to show on web?
Thanks anyone, who can give me any advice.
Satoshi

View 2 Replies View Related

Can I Use A SqlDataSource Control Exclusively To Pass Data To A Stored Procedure For Execution (insert/update Only)?

Feb 28, 2008

Hi,
I'm reasonably new to ASP.NET 2.0
I'm in my wizard_FinishButtonClick event, and from here, I want to take data from the form and some session variables and put it into my database via a stored procedure.  I also want the stored procedure to return an output value.  I do not need to perform a select or a delete.
For the life of me, I can't find a single example online or in my reference books that tells me how to accomplish this task using a SqlDataSource control.  I can find lots of examples on sqldatasources that have a select statements (I don't need one) and use insert and update sql statements instead of stored procedures (I use stored procedures).
I desperately need the syntax to:
a) create the SqlDataSource with the appropriate syntax for calling a stored procedure to update and/or insert (again, this design side of VS2005 won't let me configure this datasource without including a select statement...which I don't need).
b) syntax on how to create the parameters that will be sent to the stored procedure for this sqldatasource (including output parameters).
c) syntax on how to set the values for these parameters (again...coming from form controls and session variables)
d) syntax on how to execute, in the code-behind, the stored procedure via the sqldatasource.
If anybody has sample code or a link or two, I would be most appreciative.
Thank you in advance for any help!

View 5 Replies View Related

Read Single Piece Of Data From SqlDataSource To A Variable?

Jan 17, 2006

First I want to say thanks to the folks how have helped me over the past week or two.
I'm missing a crucial piece of insight. How do I read a single piece of data from a SqlDataSource which only hold one row of data into a declared variable?
string zUserName = SqlDataSource.(get the value in the row that is labeled UserName)
It really doesn't matter to me whether it is an SqlDataSource or some other data container that hold the data I've selected. My goal is to be able to read some data from some predefined datasource into a declared variable.
If I am approaching this problem in the wrong way any advice or article links you could give me would be grealy appreciate.
Thanks, Bill

View 1 Replies View Related

SELECT A Single Row With One SqlDataSource, Then INSERT One Of The Fields Into Another SqlDataSource

Jul 23, 2007

What is the C# code I use to do this?
I'm guessing it should be fairly simple, as there is only one row selected. I just need to pull out a specific field from that row and then insert that value into a different SqlDataSource.

View 7 Replies View Related

Sqldatasource Control

Oct 23, 2007

please explain selectparameters and conflict detection property within sqldatasource control
mohsen

View 1 Replies View Related

Sqldatasource Control

May 6, 2008

hi friends,
I created sqldatasource control. In select command i written the query like this  "select * form emp" and bounded in grid.How can I change the query for searching the details according the date wise when i click the search button.
 

View 14 Replies View Related

SqlDataSource Control

Jun 7, 2008

Hello experts
i have a SqlDataSource Control on my web form. Here is the source for the control
<asp:SqlDataSource ID="sqlSearchDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:DbefomsConnectionString %>"
SelectCommand="SELECT [icon], [file_name], [path] FROM [tblfile] WHERE ([file_name] = @file_name)">
<SelectParameters>
<asp:ControlParameter ControlID="txtSearch" DefaultValue="0" Name="file_name" PropertyName="Text"
Type="String" />
</SelectParameters>
</asp:SqlDataSource>
This control displays icon, file_name, path in GridView Control
The problem is How can i store the above field values in an asp.net variable.
Thanks
Regards
Ali

View 1 Replies View Related

Using The Sqldatasource Control

Dec 7, 2005

Do you have to use the sqldatasource in conjuction with another control like gridview or dropdown list?
I'd like to check to see if a record exists in one table before inserting data into another.
 
thanks
 

View 1 Replies View Related

SqlDataSource Control

Jan 31, 2006

Hello.I'm new to ASP.NET and trying to write data to a Microsft SQL Server. I have created a SqlDataSource control, which is 'connected' to my SQL server.Now my question is how i can put data in the database throw the control, and read data from it. I've read the site, but it's still unclear for me..Greetings!

View 1 Replies View Related

SqlDataSource Control Timeout

Aug 8, 2006

How do you set a timeout for an SqlDataSource control?

View 1 Replies View Related

How To Control SqlDataSource If We Know Only DataSourceID ?

Jan 16, 2007

Anyone can help me ?

View 4 Replies View Related

SqlDataSource Control Error

Jan 19, 2007

Hello:
I am having a little issue with an error that is frustrating me. I have a SqlDataSource within an asp:label control and also have a two dropdownlists inside that asp:label control also. When I select from the first dropdownlist, it should enable the second dropdownlist with the populated data, but instead I receive.
The SqlDataSource control 'sqlGetMLSByCity' does not have a naming container.  Ensure that the control is added to the page before calling DataBind.
Any ideas why this would be? Here is the web from portion:
<asp:Label ID="recip_form_request" runat="server" Visible="false">    <ul>        <li>Step one: Select listing type.</li>        <li>Step two: Select the City that you are reciprocating to.</li>        <li>Step three: Complete the Recip Form.</li>    </ul>    <asp:DropDownList ID="recip_form_type" runat="server" AutoPostBack="true" Visible="False">        <asp:ListItem Value="0" Text="(Select Form)"></asp:ListItem>        <asp:ListItem Value="1" Text="Residential"></asp:ListItem>    </asp:DropDownList>    <br />    <asp:DropDownList ID="outside_assoc_cities" runat="server" AutoPostBack="True" Enabled="False" DataTextField="city" DataValueField="id" Visible="False"></asp:DropDownList><br />    <asp:Label ID="city_mls_desc" runat="server"></asp:Label><br />    <asp:Button ID="page1_btn" runat="server" Text="Next >>" Visible="False" />    <asp:SqlDataSource ID="sqlCities" runat="server" ProviderName="System.Data.SqlClient" ConnectionString="<%$ AppSettings:connectionstring %>" SelectCommandType="Text" SelectCommand="SELECT id, city FROM  tCityMaster"></asp:SqlDataSource>    <asp:SqlDataSource ID="sqlGetMLSByCity" runat="server" ProviderName="System.Data.SqlClient" ConnectionString="<%$ AppSettings:connectionstring %>">        <SelectParameters>            <asp:ControlParameter ControlID="outside_assoc_cities" Name="City" />        </SelectParameters>    </asp:SqlDataSource></asp:Label>
then the code behind:
Protected Sub outside_assoc_cities_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles outside_assoc_cities.SelectedIndexChanged        If outside_assoc_cities.SelectedIndex > -1 Then            Dim ItemId As Integer = Integer.Parse(outside_assoc_cities.SelectedValue)            Dim MLSID As String = Nothing
            Dim cmd As New SqlCommand            Dim con As New SqlConnection            cmd.Connection = con
            Dim sqlGetMLSByCity_sql As SqlDataSource = CType(Page.FindControl("sqlGetMLSByCity"), SqlDataSource)            'using connectionstring from SqlDataSource Control            con.ConnectionString = sqlGetMLSByCity_sql.ConnectionString            'con.ConnectionString = sqlGetMLSByCity.ConnectionString
            cmd.CommandType = CommandType.Text            cmd.CommandText = "SELECT mls_id FROM pwaordev..tCityMaster WITH(NOLOCK) WHERE ID=@ID"
            cmd.Parameters.Add("@ID", SqlDbType.Int, 4).Value = ItemId
            Try                con.Open()                MLSID = cmd.ExecuteScalar                con.Dispose()                cmd.Dispose()            Catch ex As Exception                con.Dispose()                cmd.Dispose()                Response.Write(ex.ToString())            End Try
            'Further logic to display button depending on MLS            If Not String.IsNullOrEmpty(MLSID) Then                If MLSID = "B" Then                    city_mls_desc.Text = "The MLS system that covers " & outside_assoc_cities.SelectedItem.Text & " is Greater South Bay MLS."                    page1_btn.Visible = True                ElseIf MLSID = "A" Then                    city_mls_desc.Text = "The MLS system that covers " & outside_assoc_cities.SelectedItem.Text & " is Big Bear BOR, MLS, which is not covered by Pacific West Association of REALTOR&reg, please contact us for more information."                    page1_btn.Visible = False                ElseIf MLSID = "C" Then                    city_mls_desc.Text = "The MLS system that covers " & outside_assoc_cities.SelectedItem.Text & " is Combined L.A./Westside MLS."                    page1_btn.Visible = True                ElseIf MLSID = "F" Then                    city_mls_desc.Text = "The MLS system that covers " & outside_assoc_cities.SelectedItem.Text & " is Crisnet MLS, which is not covered by Pacific West Association of REALTOR&reg, please contact us for more information."                    page1_btn.Visible = False                ElseIf MLSID = "Y" Then                    city_mls_desc.Text = "The MLS system that covers " & outside_assoc_cities.SelectedItem.Text & " is DCAoR - Yucca Valley Area, which is not covered by Pacific West Association of REALTOR&reg, please contact us for more information."                    page1_btn.Visible = False                ElseIf MLSID = "D" Then                    city_mls_desc.Text = "The MLS system that covers " & outside_assoc_cities.SelectedItem.Text & " is Desert Area MLS."                    page1_btn.Visible = True                ElseIf MLSID = "L" Then                    city_mls_desc.Text = "The MLS system that covers " & outside_assoc_cities.SelectedItem.Text & " is i-Tech Glendale/Pasadena."                    page1_btn.Visible = True                ElseIf MLSID = "M" Then                    city_mls_desc.Text = "The MLS system that covers " & outside_assoc_cities.SelectedItem.Text & " is MRM - Multi-Regional MLS."                    page1_btn.Visible = True                ElseIf MLSID = "R" Then                    city_mls_desc.Text = "The MLS system that covers " & outside_assoc_cities.SelectedItem.Text & " is RIM - Rim of the World MLS, which is not covered by Pacific West Association of REALTOR&reg, please contact us for more information."                    page1_btn.Visible = False                ElseIf MLSID = "G" Then                    city_mls_desc.Text = "The MLS system that covers " & outside_assoc_cities.SelectedItem.Text & " is SDI - San Diego, which is not covered by Pacific West Association of REALTOR&reg, please contact us for more information."                    page1_btn.Visible = False                ElseIf MLSID = "S" Then                    city_mls_desc.Text = "The MLS system that covers " & outside_assoc_cities.SelectedItem.Text & " is SOCAL MLS - Southern California MLS."                    page1_btn.Visible = True                ElseIf MLSID = "T" Then                    city_mls_desc.Text = "The MLS system that covers " & outside_assoc_cities.SelectedItem.Text & " is Outside Area, which is not covered by Pacific West Association of REALTOR&reg, please contact us for more information."                    page1_btn.Visible = False                End If                'test.Text = MLSID                'If test.Text = "L" Then                'mls_text.Text = "i-Tech"                'End If            End If        End If    End Sub
Any help would be great, thank you!

View 1 Replies View Related

How To Control The Loading Of SqlDataSource?

Sep 20, 2007

I have an SqlDatSource that I have fully setup at design time, but I don't want it to open and load as soon as the page loads, instead I want to open it based on a condition.
How do you do that with a DataSource?
I know that I can simply remove the Select query, and then set it at run time, but I'm looking for something better, that allows me to have the Select query set at design time, in part because I have a lot of parameters.

View 3 Replies View Related

SqlDataSource Control Synchronization

Sep 29, 2007

Hello:
I have two SqlDataSource controls on two different pages: one is updating a table and the other is reading from the same table.
Now is it possible that the reader SqlDataSource control can be refreshed immediately (to reflect updates) when the other control updates the table?

View 1 Replies View Related

UpdateCommand In Sqldatasource Control

Oct 15, 2007

Hello all,
I am trying to update the record which involed the modification of key in Datakeynames, but when i click the update button from gridview, it doesn't allow to change the value of modified column.
<asp:SqlDataSource ID="SqlDataSource1" runat="server" DataSourceMode="DataSet"                 ConnectionString="<%$ ConnectionStrings:WebsiteDataConnection %>" OldValuesParameterFormatString="old_{0}"                SelectCommand="SELECT * FROM [ServiceAgents]"                InsertCommand="INSERT INTO ServiceAgents VALUES(@Ser_STATE, @Ser_CITY, @Ser_AGENT, @Ser_PHONE, @Ser_EQUIPMENT)"                UpdateCommand="UPDATE ServiceAgents SET AGENT=@AGENT, PHONE=@PHONE WHERE (STATE=@STATE and CITY=@CITY and AGENT=@old_AGENT and EQUIPMENT=@EQUIPMENT)"                DeleteCommand="DELETE FROM ServiceAgents WHERE (STATE=@STATE and CITY=@CITY and AGENT=@AGENT and EQUIPMENT=@EQUIPMENT)" >                                <UpdateParameters>                    <asp:Parameter Type="String" Name="AGENT" />                    <asp:Parameter Type="String" Name="PHONE" />                                         <asp:Parameter Name="old_AGENT" />                    <asp:Parameter Type="String" Name="STATE" />                    <asp:Parameter Type="String" Name="CITY" />                    <asp:Parameter Type="String" Name="EQUIPMENT" />                </UpdateParameters>                                <InsertParameters>                    <asp:ControlParameter Name="Ser_STATE" ControlID="TextBox_state"/>                    <asp:ControlParameter Name="Ser_CITY" ControlID="TextBox_city"/>                    <asp:ControlParameter Name="Ser_AGENT" ControlID="TextBox_agent"/>                    <asp:ControlParameter Name="Ser_PHONE" ControlID="TextBox_phone"/>                    <asp:ControlParameter Name="Ser_EQUIPMENT" ControlID="TextBox_equip" />                   </InsertParameters>                                <DeleteParameters>                   <asp:Parameter Type="String" Name="STATE" />                    <asp:Parameter Type="String" Name="CITY" />                    <asp:Parameter Type="String" Name="AGENT" />                    <asp:Parameter Type="String" Name="EQUIPMENT" />                </DeleteParameters>                            </asp:SqlDataSource>
Does anyone got any ideas about it? Where is wrong in the control?

View 3 Replies View Related

FilterExpression And The SQLDataSource Control

Feb 16, 2008

I have a SQLDatasource control on a web page. It is the datasource for a gridview control.I want the gridview to show all jones if the FirstName textbox is left blank or empty. Right now I have to put a % in the FirstName textbox to get what I want. If I make the FirstNameTextBox empty or remove the % from the FirstNameTextbox it returns all the names in the database no matter what the last name is.How do I get it to work without having to use the % in the FirstName Textbox? THANKS!FilterExpression="LastName LIKE '%{0}%' and FirstName LIKE '%{1}%'"><FilterParameters>            <asp:ControlParameter ControlID="LastNameTextBox" Name="LastName" PropertyName="Text" DefaultValue="" />            <asp:ControlParameter ControlID="FirstNameTextBox" Name="FirstName" PropertyName="Text" DefaultValue="" /></FilterParameters>
Last Name: Jones___________First Name: %_____________FILTERBUTTON
GridviewLast Name      First NameBob                JonesBill                 Jones
 

View 6 Replies View Related

SqlDataSource And Wizard Control

Apr 8, 2008

I have not found anything useful on the Wizard control.  Anything I can find gets to the last step and then just takes the info you supplied and applies them to a bunch of Label.Text's - none that do work. 
So I am building a Wizard control for an HR system that will insert the information into SQL through a SqlDataSource.  The problem is, only the controls that are present in whichever step is currently selected in VWD will appear in the Command and Parameter Editor.
I tried to work around it by selecting the first step, then applying the controls in step 1 within the Parameter Editor, but when I go back to do step 2, it erases everything I just did for step 1.
How do I implement the Wizard with a SqlDataSource?

View 8 Replies View Related

Confused Need Help With SQLDataSource Control

Jun 2, 2008

I have a gridview that is tied to a SQLDataSource control. As the gridview is filled some of the ASPX code calls some code in the code behind page. Where I am having trouble is that in one of these calls I need to some how pass the id filed ("LISTID")of the table for the SQL statement in the code behind page and I'm not sure how to do it.
The code behind function is always using the same id and I do not know how to change it. Below is all the code.
 
Here is the calling code in the ASPX page.
"DeleteBtn" Visible='<%# IsDeleteBtnVisible %>' runat="server" CausesValidation="False" CommandName="Delete" Text="Delete" ForeColor="#003399"> Here is the entire ASPX code.     class="header">            class="title">My Lists         "Span1">            Current List Filter:             "DropDownList2" cssclass="filterdropdown" AutoPostBack="true" runat="server">                "Active" Value="False">                "Done" Value="true">                                    --------------------------------------------------------------------------------"separator2"/>                        "list2">        "ScriptManager1"  EnablePartialRendering="true"  runat="server">          "Up2" UpdateMode="Conditional" runat="server">                                                                  "GridView1" runat="server" AutoGenerateColumns="False"                         DataKeyNames="LISTID" DataSourceID="SqlDataSource1"                        AllowPaging="True" AllowSorting="True" EnableViewState="False" GridLines="None"                         AlternatingRowStyle-BackColor="#FFFFCC" AlternatingRowStyle-Font-Size="Small"                         ForeColor="#FFFFCC" Font-Size="Small" AlternatingRowStyle-ForeColor="Black"                         Width="100%" HeaderStyle-ForeColor="White">                                                     "False">                                                            "LinkButton1" runat="server" CausesValidation="True" CommandName="Update" Text="Update" ForeColor="#003399">                                "LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" ForeColor="#003399">                                                                                        "LinkButton1" runat="server" CausesValidation="False" CommandName="Edit" Text="Edit" ForeColor="#003399">                                "DeleteBtn" Visible='<%# IsDeleteBtnVisible %>' runat="server" CausesValidation="False" CommandName="Delete" Text="Delete" ForeColor="#003399">                                                        "buttons">                            "commands">                                                                        "ITEM_DETAILS"  HeaderText="Details"  SortExpression="ITEM_DETAILS" ControlStyle-ForeColor="#003399">                            "name_edit">                            "name">                            "name">                                                                        "Pri" itemStyle-HorizontalAlign="Center" SortExpression="Priority" ControlStyle-ForeColor="#003399">                                                            "DropDownList1" Width="75" SelectedValue='<%# Bind("Priority") %>' runat="server">                                    "High" Value="3">                                    "Medium" Value="2">                                    "Low" Value="1">                                                                                                                                                        "pri" Text='<%# FormatPriority(Eval("Priority")) %>' runat="server">                                                        "priority">                            "#003399">                            "priority">                                                                        "DUEDATE" itemStyle-HorizontalAlign="Center"                              HeaderText="Due Date" DataFormatString="{0:MM/dd/yyyy}"                            SortExpression="DUEDATE" >
                            "Center">                        
                        "COMPLETEDON" itemStyle-HorizontalAlign="Center"                              HeaderText="Completed On" DataFormatString="{0:MM/dd/yyyy}"                            SortExpression="COMPLETEDON" >
                            "Center">                        
                        "Done" itemStyle-HorizontalAlign="Center" SortExpression="IsComplete">                                                            "CheckBox1" runat="server" Checked='<%# Bind("IsComplete") %>'>                                                        "iscomplete">                            "iscomplete">                                                            "Done" Text='<%# FormatDone(Eval("IsComplete")) %>' runat="server">                                                                                           
                                                                                                "Button2" runat="server" CommandName="Something" DataTextField="LISTID" DataTextFormatString="{0} active items" text='<%# Eval("LISTID") %>'>                                                                                                                                                                                                  "Empty">No lists                                                                        "White">                        "#FFFFCC" Font-Size="Small" ForeColor="Black">                                                                                                                         "Div1">               "Up3" UpdateMode="Conditional"  runat="server">                                            Add New List: "AddItem2" cssclass="newitem"                     runat="server">                "Button1" runat="server" OnClick="AddListBtn_Click" Text="Add">                                "txtdate" runat="server">                                                        "Button1" EventName="Click">                                                                        "SqlDataSource1" runat="server"         ConnectionString="&lt;%$ ConnectionStrings:FastTrackConnectionString %>"         SelectCommand="SELECT * FROM [TODO]">     Here is the code behind page code. Protected Function IsDeleteBtnVisible() As Boolean        '        Return IIf(itemCount = 0, True, False)
        'This is for my gridview        Dim strConn2 As SqlConnection = New SqlConnection        Dim cmd2 As SqlCommand = New SqlCommand        Dim rs2 As SqlDataReader        Dim test1 As String        Dim test2 As String
        strConn2.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings("FastTrackConnectionString2").ToString()        strConn2.Open()
        cmd2.Connection = strConn2        cmd2.CommandText = "SELECT LISTID, (SELECT COUNT(0) AS ItemCount FROM TODO_SUB_ITEMS WHERE(LISTID = TODO.LISTID) AND (ISCOMPLETE ='False')) AS ItemCount FROM TODO WHERE (ISCOMPLETE ='False')"
        rs2 = cmd2.ExecuteReader()
        rs2.Read()
        Dim testlistid As Integer = rs2(0)        Dim intholder As Integer = rs2(1)
        strConn2.Close()        cmd2 = Nothing        strConn2 = Nothing
        Return IIf(intholder = 0, True, False)
    End Function

View 7 Replies View Related

Another SQLDataSource Control Question

Jun 4, 2008

I have a gridview that is filled from a SQLDataSource control when the page loads.
I need to do some updates and delets on this data and I wanted to know can you add more than one SQL statement to a SQLDataSource control or do I have to have a seprate control for each operation?
The SQL currently is just the standard SELECT *, I cannnot see a way to add statments.
Thanks,
Ty

View 3 Replies View Related

Question Regarding The SqlDataSource Control

Jun 11, 2008

There is something I don't understand or I am just missing something here.
Why is it that I can place an SqlDataSource1.Insert() or update, or delete, but not an SqlDataSource.Select() inside a button click event "for an example" without getting an Compilation Error?
Thanks,
xyz789

View 2 Replies View Related

SqlDataSource Control Does Not Appear In Designer

Feb 1, 2006

I have dragged 3 SqlDataSource Controls to the WebDesigner and none are appearing graphically in the Designer View, but they are in the Source View.  How can I get the control to appear in the designer.
 
Thanks,
Mark

View 5 Replies View Related

Configuring A SQLDatasource Control

Feb 26, 2006

When I configure a SQLDataSource control I want the following where clause...
WHERE     (RegionID = @RegionID AND DistrictID IS NULL AND CampusID IS NULL) OR (DistrictID = @DistrictID AND CampusID IS NULL ) OR(CampusID = @CampusID AND UserRole = 'CampusAdmin') OR (CampusID = @CampusID)but it gets reformated as....
WHERE     (RegionID = 'Region10') AND (DistrictID IS NULL) AND (CampusID IS NULL) OR                      (DistrictID = 2) AND (CampusID IS NULL) OR (CampusID = '999999103') AND (UserRole = 'CampusAdmin') OR                       (CampusID = '999999103')I don't think these are functionaly equivelant, are they?If not how do I stop the 'wizard' from reformatting the SQL where clause?Thanks

View 3 Replies View Related

Sqldatasource Control Inserting Problems

Oct 6, 2006

I set up a Sqldatasource control in 2.0 and I can retrieve data through a SQL Server connection from a stored procedure.  My problem is when I set up the insert command object through the wizard for the Sqldatasource control with another stored procedure for inserting data and call the insert method of my Sqldatasource object i get nothing not even an error it just goes through the code like nothing was wrong and I don't get anything inserted.  I don't know if this could be a problem but one of the parameters in the stored procedure is declared like this: @return tinyint output. I don't know how the Sqldatasource accounts for return parameters.  Here is the code for the insert for the Sqldatasource object.<asp:SqlDataSource ID="sdsMain" runat="server" ConnectionString="<%$ ConnectionStrings:SN_CUSTOMERConnectionString %>"InsertCommand="uspSNOrder_Promo_Live" InsertCommandType="StoredProcedure" SelectCommand="uspOPFillPromo"SelectCommandType="StoredProcedure"><InsertParameters><asp:ControlParameter ControlID="ddlPromo" Name="promoid" PropertyName="SelectedValue"Type="Int32" /><asp:Parameter DefaultValue="1" Name="datasourceid" Type="Int32" /><asp:Parameter DefaultValue="0" Name="datasourcekey" Type="String" /><asp:Parameter DefaultValue="9" Name="salesroomid" Type="Int32" /><asp:Parameter DefaultValue="9999" Name="userid" Type="Int32" /><asp:ControlParameter ControlID="txtFName" DefaultValue="" Name="firstname" PropertyName="Text"Type="String" /><asp:ControlParameter ControlID="txtLName" Name="lastname" PropertyName="Text" Type="String" /><asp:ControlParameter ControlID="txtAddress" Name="address" PropertyName="Text" Type="String" /><asp:ControlParameter ControlID="txtCity" Name="city" PropertyName="Text" Type="String" /><asp:ControlParameter ControlID="txtState" Name="state" PropertyName="Text" Type="String" /><asp:ControlParameter ControlID="txtZip" Name="zip" PropertyName="Text" Type="String" /><asp:ControlParameter ControlID="txtPhone" Name="phone" PropertyName="Text" Type="String" /><asp:ControlParameter ControlID="txtEmail" Name="email" PropertyName="Text" Type="String" /><asp:ControlParameter ControlID="ddlStatus" Name="status" PropertyName="SelectedValue"Type="Int32" /><asp:Parameter DefaultValue="0" Direction="InputOutput" Name="return" Type="Byte" /></InsertParameters></asp:SqlDataSource>Thanks in advance

View 1 Replies View Related

Sqldatasource Server Control Problem

Apr 2, 2007

Dear all,I am couping a dropdownlist and a sqldatasource control to display a column from a database of SQL/Server on browser. However, when I tried to configure the sqldatasource to let it get data from SQL/Server, it always report an error. It normally happens at the first step of creating new connection. After I specified the correct sql/server instance name, using SQL server authentication, and select a database name. Even the connection test can sucessfully passed. However, when I click the "OK" button, an error message saying "object reference not set to an instance of an object" popped out and I could not add new connections. The strange thing is that after I reintall the visual studio 2005 service pack 1. It will function properly for a while. After sometime, it will fail again.  Anybody has suggestions? Thanks a lot! 

View 1 Replies View Related

Stored Prcedures And SQLDataSource Control

May 28, 2008

Is it possible to place a stored procedure in a SQLDataSource control that needs a variable input then run it later?
DETAILS
I have 2 pages with gridview controls that are linked to a SQLDataSource controls.
What I would like to do is when the user clicks on a link in the gridview of the first page I want to take the value of the link clicked and pass it to the second page where it is placed into a variable that would be used in a WHERE clause to fill the second pages gridview.
I have no problem getting the value into a variable in the page load event of the second page. What I would be nice is since the gridview is already tied to a SQLDataSource control with the columns specified is if I could some how pass the variable to a stored procedure in the control so I don't have to manually pull and fill the data.
Any thoughts would be apperciated.
Thanks,
Ty 
 
 

View 3 Replies View Related

Timestamp Concurrency Control With SQLDataSource

Nov 10, 2005

I am trying to use a 'timestamp' type column with SQLDataSource for concurrency control with SQL Server.  I'm getting the following error:
Operand type clash: timestamp is incompatible with sql_variant
It appears that the problem is that the value for the Type property of the Parameter (which was generated by the SqlDataSource wizard) is Object which maps to 'sql_variant' rather than to 'timestamp'.
I know that the older way of doing things with SqlDataAdapter, SqlCommand, SqlParameter can handle timestamps because SqlParameter has a SqlDbType property that can have a value of SqlDbType.Timestamp, but I don't see how to do this with the newer SqlDataSource, Parameter classes because the Parameter.Type property (of type TypeCode) doesn't have a Timestamp value.
Has anyone been able to use a 'timestamp' type field with SqlDataSource?
Here's my sample code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="MyTestPage.aspx.cs" Inherits="MyTestPage" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"><title>Untitled Page</title></head><body><form id="form1" runat="server"><div><asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1"EmptyDataText="There are no data records to display." DataKeyNames="MyID"><Columns><asp:CommandField ShowEditButton="True" /><asp:BoundField DataField="MyID" HeaderText="MyID" InsertVisible="False" ReadOnly="True"SortExpression="MyID" /><asp:BoundField DataField="MyDesc" HeaderText="MyDesc" SortExpression="MyDesc" /></Columns></asp:GridView><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConflictDetection="CompareAllValues"ConnectionString="<%$ ConnectionStrings:CtrlConnectionString1 %>" DeleteCommand="DELETE FROM [MyTest] WHERE [MyID] = @original_MyID AND [MyDesc] = @original_MyDesc AND [timestamp] = @original_timestamp"InsertCommand="INSERT INTO [MyTest] ([MyDesc], [timestamp]) VALUES (@MyDesc, @timestamp)" OldValuesParameterFormatString="original_{0}"ProviderName="<%$ ConnectionStrings:CtrlConnectionString1.ProviderName %>" SelectCommand="SELECT [MyID], [MyDesc], [timestamp] FROM [MyTest]"UpdateCommand="UPDATE [MyTest] SET [MyDesc] = @MyDesc WHERE [MyID] = @original_MyID AND [MyDesc] = @original_MyDesc AND [timestamp] = @original_timestamp"><DeleteParameters><asp:Parameter Name="original_MyID" Type="Int32" /><asp:Parameter Name="original_MyDesc" Type="String" /><asp:Parameter Name="original_timestamp" Type="Object" /></DeleteParameters><UpdateParameters><asp:Parameter Name="MyDesc" Type="String" /><asp:Parameter Name="timestamp" Type="Object" /><asp:Parameter Name="original_MyID" Type="Int32" /><asp:Parameter Name="original_MyDesc" Type="String" /><asp:Parameter Name="original_timestamp" Type="Object" /></UpdateParameters><InsertParameters><asp:Parameter Name="MyDesc" Type="String" /><asp:Parameter Name="timestamp" Type="Object" /></InsertParameters></asp:SqlDataSource></div></form></body></html>

View 3 Replies View Related

Bind The Asp:SqlDataSource To A Label Control

Nov 12, 2005

how can i display the result of an  asp:SqlDataSource into a lable control.the sqldatasource returns the count for some thing ie "select count(*) as total from tbl"please help

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved