DataSource Resetting SelectCommand Property Between Reposts

Mar 25, 2008

Hi
 I have a DataSource control which is currently set with no initial SelectCommand Property when it is constructed.
 
I have a number of standard buttons, each of which when clicked fires an event that analyses and modifies the SelectCommand for the DataSource.
 
Each event sets the SelectCommand Property for the DataSource using eg:
dataSource.SelectCommand = "SELECT * FROM table WHERE tableID IN ('1', '2', '3')";

(To help you understand, the aim is to have each button either inserting or removing an ID number into an SQL 'IN' clause as shown above) 
When the events are fired the DataSource is updated with the new SelectCommand and the bound ListBox updates correctly. However any subsequent events don't seem to read the previously modified SelectCommand setting. When they try to read the SelectCommand using:
string queryToModify = dataSource.SelectCommand;
They just get a empty string returned instead of the query that the previous button click set (temporarily).
 It seems like a state issue, but as a server side control it should automatically keep the state, right?
 
Thanks for taking the time to read this and many thanks in advance for any assistance (I've only been learning ASP.NET for a few days... and I'm quite impressed so far :-) )
 
PurplePerson

 
 

 

View 1 Replies


ADVERTISEMENT

Dynamically Change The SelectCommand Property

Nov 8, 2007

Hello
I have a gridview that I use on a products page, my problems is certain products have different attributes that I would like to display.
Therefore what I would like to do is change the SelectCommand property to my SQLDatasource depending on the querystring that is passed.
For instance in my page load event I would have a CASE statement with numerous SQLString Variables.
Here is the current coding for my datasource
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"

SelectCommand="SELECT PS.ProductSizeMM AS [Coupling Size], PS.ProductWallThickness AS [To Suit], PS.Cost AS [Price], PS.Sold_By AS [Sold by] FROM tblProduct AS P INNER JOIN tblProductSize AS PS ON P.ProductCode = PS.ProductCode WHERE (P.ProductDescription = @ProductDescription) ORDER BY PS.Sorter">
<SelectParameters>
     <asp:QueryStringParameter Name="ProductDescription" QueryStringField="ProductDescription" />
</SelectParameters>
</asp:SqlDataSource>I have tried declaring a string variable in my page load event (SQLString) then setting the
SelectCommand="SQLString" but this causes a syntax error
Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near 'SQLString'.
Any help would be greatly appreicated!!

View 3 Replies View Related

The 'DataSource' Property Cannot Be Set Declaratively

Aug 24, 2007

This my code for a blog page that shows active blogs:
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Title="Blogs"%><asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<h3>My blogs</h3>
<asp:GridView ID="Gridview1" runat="server" AllowPaging="true" AutoGenerateColumns="false" DataSource="SqlDataSource1">
<Columns>
<asp:TemplateField>
<HeaderTemplate>
Blog
</HeaderTemplate>
<ItemTemplate>
<b><asp:LinkButton ID="LinkButton1" runat="server" Text='<%#Bind("name") %>'
PostBackUrl='<%#Bind("blogid" "Blog.aspx?Blog={0}" %>' />
 
<br/>
<asp:Label ID="label2" runat="server" Text='<%#Bind ("description") %>' />
 
</ItemTemplate>
<HeaderStyle HorizontalAlign="Left" />
<ItemStyle Width="250px"/>
</asp:TemplateField>
<asp:BoundField DataField="username" HeaderText="Owner">
<HeaderStyle HorizontalAlign="Left" Width="100px" />
<ItemStyle HorizontalAlign="Left" Width="100px" />
</asp:BoundField>
<asp:BoundField DataField="posts" HeaderText="posts">
<HeaderStyle HorizontalAlign="Left" />
<ItemStyle HorizontalAlign="Left" Width="80px" />
</asp:BoundField>
 </Columns>
</asp:GridView><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ConnectionStrings:BlogConnectionStrings%>"
SelectCommand="SELECT [blogid], [name], [description], [username], [posts] from [Blogs] ORDER By[name]">
</asp:SqlDataSource> </asp:Content>
Compiling that i get the error in the subject specifically for line 4 (in bold). Any ideas?

View 3 Replies View Related

Changing Code Page Property Using Property Expression Doesn't Work

Jun 16, 2006

I am having problems exporting data into a flat file using specific code page. My application has a variable "User::CodePage" that stores code page value (936, 950, 1252, etc) based on the data source. This variable is assigned to the CodePage property of desitnation file connection using Property expression.

But, when I execute the package, the CodePage property of the Destination file connection defaults to the initial value that was set for "User:CodePage" variable in design mode. I checked the value within the variable during runtime and it changes correctly for each data source. But, the property of the destinatin file connection doesn't change and results in an error.

[Flat File Destination [473]] Error: Data conversion failed. The data conversion for column "Column01" returned status value 4 and status text "Text was truncated or one or more characters had no match in the target code page.".

[DTS.Pipeline] Error: The ProcessInput method on component "Flat File Destination" (473) failed with error code 0xC02020A0. The identified component returned an error from the ProcessInput method. The error is specific to the component, but the error is fatal and will cause the Data Flow task to stop running.

If I manually update the variable with correct code page and re-run the ETL, everything works fine. Just that it doesn't work during run-time mode.

Can someone please help me resolve this.

Thanks much.

View 5 Replies View Related

Value Of A Readonly Property Of Custom Task Is Not Updated In Property Window

Apr 17, 2008

Hi,

I developed a simple custom control flow component which has several read/write properties and one readonly property (lets call it ROP) whichs Get method simple returns the value of a private variable (VAR as string). In the Execute method the VAR has a value assigened. When I put the value of ROP or VAR into MsgBox I can see the correct value. However when I execute the component I can not see the value of the ROP in the property window. I see the property but its value is empty string. For example when I put a breakpoint to postexecute or check the property before click OK in a MsgBox I would expect that the property value would be updated in SSIS as well. Is there a way how to display correct values of custom tasks properties in property window?

Thanks for any hints.

View 3 Replies View Related

(URGENT) Cannot Be Written To The Property. The Expression Was Evaluated, But Cannot Be Set On The Property

May 7, 2008

Untill recently I had a smooth running SSIS package,but suddenly it throws error syaing
"OnError,,,,,,,The result of the expression

"@[User:trTextFileImpDirectory] +"SomeTextStringHere"+ @[User:trANTTextFileName] +(DT_STR,30,1252) @[User:taging_Date_Key]+ "SomeTextStringHere"
" on property "ConnectionString" cannot be written to the property. The expression was evaluated, but cannot be set on the property."

I have child SSIS package running under a parent package (through execute package task)

I have few flat file connection managers in child package for text file import , in which I am building text file path dynamically at run time by assigning an expression in connection string property of connection manager.
The Expression is as follows



"@[User:trTextFileImpDirectory] +"SomeTextStringHere."+ @[User:trANTTextFileName] +(DT_STR,30,1252) @[User:taging_Date_Key]+ +"SomeTextStringHere"

Where @[User:trTextFileImpDirectory] is a variable which contains path of directory containg text
files.Value in this variable is assigned at runtime from parent package's variable,which in turns fetch
value from a configuration file on local server.

With my current configuration this path has been configured to some other server's directory over network ( I.e my package picks text files from some other servers folder over network)

While
"Some string here"+ @[User:trANTTextFileName]" part of file name string.

(DT_STR,30,1252) @[User:taging_Date_Key] Contain the date of processing ,value in this variable is also picked up at run time from parent package variable.

1) So can someone give me some insight into possible reason of failures.
2) Is it possible that problem arises if directory (from which I m picking text files) is assigned password or is there exist some problem in accessing forlders over network ?
3) Or there can be some problem in package configuration at design time( I.e where I m assigning value in variable from parent package vriables)?




View 10 Replies View Related

Resetting Id Values

Oct 16, 2006

hi guys i was wondering if anyone could help me, i have a table with a field called id that did have numbers 1,2,3,4,5,6,7,8 and so on! but after some tinkering i have removed a few value and added more so i now have 1, 4,8,19,20 and so on!i was wondering if i can run a query to update those value and return them to 1,2,3,4,5,6,7,8 and so on?CheersTupps

View 2 Replies View Related

Resetting Primary Key

May 8, 2008

Hi,I have a table OutMailDetails with the following fields :   OutMailID --- Foriegn Key   Name   Description
My problem is that i have datas already in this table and the table is related to another table called OutMail through OutMailID field. Please how can i make it (OutMailID field) a primary key now.

View 2 Replies View Related

Autonumber Is Resetting

Dec 1, 2004

i am using autonumber as a primary key in one table. in my app., row from that table will be moved to another table after some time but that autonumber is important. when there are no any data in first table, and new row is inserted, autonumber starts from 1 which i don't want as there will be data redundancy when it will be moved to another table. so is there any way i can force the autonumber to start from previous value rathe than 1?

View 2 Replies View Related

Resetting Database

Aug 10, 2005

hi!i'm new to sql server and enterprise manager and i accidentally deleted all data in a table. how do i recover them? the table (CaptureManager) is still there but empty. i have the following information:if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[CaptureManager]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)drop table [dbo].[CaptureManager]GO
CREATE TABLE [dbo].[CaptureManager] ( [ID] [tinyint] IDENTITY (1, 1) NOT NULL , [Name] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [Email] [varchar] (75) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [Ext] [varchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [Status] [char] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ) ON [PRIMARY]GO

View 4 Replies View Related

Resetting Master.mdf

Aug 4, 2004

Hey! I downloaded the sql engine and made a bunch of tables in visual basic. They were called new1, new2, new3, and new4. So I deleted new1.mdf, new1.ldf, new2.mdf, etc... but I notice I still can't recreate them. So I'm thinking there's remnants in master.mdf or something?? How would I go about getting rid of all the old tables, even ones whose names I've forgotten, so I can have a clean slate again? (btw I don't have sql server, just the desktop engine)

View 4 Replies View Related

Resetting Identity Value

May 2, 2008

I am trying to reset an IDENTITY RowNumber
back to 1 in a query when the Person's Name is the same. The following query
can be used agains the pubs database in SQL Server.

I am trying to figure out where to place the section for the DBCC CHECKIDENT item in order to reset the RowNumber back to 1 when ever the lname column is the same. For example if the pub database had duplicate records for a given employee the RowNumber would reset back to 1.


CREATE TABLE #RowNumber (
RowNumber int IDENTITY (1, 1),
emp_id char(9) )
--DECLARE @seed int
--SET @seed = 1
--DBCC CHECKIDENT ('#RowNumber', RESEED , @seed) WITH NO_INFOMSGS

INSERT #RowNumber (emp_id)
SELECT emp_id
FROM employee
ORDER BY lname
SELECT RowNumber, e.emp_id, lname, fname, job_id
FROM #RowNumber r JOIN employee e
ON r.emp_id = e.emp_id

ORDER BY RowNumber
DROP TABLE #RowNumber

Ganesh

View 3 Replies View Related

Resetting DMV Stats

Feb 1, 2008

Hello all-
Is it possible to reset the values of DMV stats/counters without restarting the SQL service? I'm looking for something more than dbcc freeproccache...more along the lines of index_usage and some of the OS DMVs.

Cheers,
-Brandon Tucker

View 3 Replies View Related

Resetting SA Password

Aug 23, 2007

Hello all.

This is the best suited forum I found for my problem, if there's a better suited one please direct me.

I am running SQL Server 7.0 on Windows 2000 Server, and the SA's password has been forgotten and no other employee knows it.
I searched the net for a solution, and I found various pages describing how to reset the SA's password by logging in an administrator, connecting to the server and using a sp_password command.

For some reason, I cannot connect to the server even when I'm logged on as administrator.
Here are the steps I took:

1) I logged in as DOMAINAdministrator at my domain controller.
2) I opened Enterprise Manager and clicked on the server labeled "(LOCAL)". The server is registered to use "Windows NT authentication".
3) Received the following error:"A connection could not be established to (LOCAL) - Login failed for user 'DOMAINAdministrator'.. Please verify that SQL Server is running and check your SQL Server registration properties ... and try again". If there was an option to attach a screenshot, I would, but...
4) I have verified that SQL Server is running.

As I am new to SQL Server, I'm not sure about this, but the SQL Server is called SERVERNET, and the domain I'm logged into is called DOMAIN.
Should I login as an administrator to SERVERNET and not to DOMAIN? Is that possible? "SERVERNET" does not show on the login screen, only "DOMAIN" is listed there.

Any help will be appreciated.

Thanks

View 5 Replies View Related

Resetting IDENTITY

Apr 18, 2008

I've seen a lot of solutions to reset the an Identity Field, but the one I found in the website I mentioned worked fine in SQL 2005 Express Edition.

http://www.howtogeek.com/howto/database/reset-identity-column-value-in-sql-server/

The other solutions in SQL 2005 that use ALTER TABLE and ALTER COLUMN just don't work, I don't no Why.

Paulo Alexandre

View 1 Replies View Related

If Then In A SelectCommand

May 12, 2007

Hi all,
I want to do something like this, but I cannot get it working:
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:AFS_WAWI_DBConnectionString1 %>"<%If Session("my") = "123" thenSelectCommand="SELECT [nr1] FROM [Artikel]"ElseSelectCommand="SELECT [nr2] FROM [Artikel]"End if %></asp:SqlDataSource>
 Is that possible and how can I manage that?
Thanks for your answers, Chris.

View 4 Replies View Related

Identity Column Resetting

May 2, 2001

If there are gaps ( due to deletions ) in indentity column, how do I
resequence the values ? As well as how to reset the last used number ?

Info. is greatly appreciated.

Ivan

View 1 Replies View Related

Resetting Identity Values Of PKs

Sep 21, 2000

What is the easiest way in T-SQL to reset the identity values of
the PK columns in a DB. Here's the scenario.

I'm going to be backing up a HUGE DB and then restoring
it to a new server. Once there I will run an SP to remove all the existing
data. The tables are now row-free. However my customer doesn't like that
the first record they add gets PK value of 5,321, or whatever.

After I remove all the data how can I reset the ids?
It would be nice to add some code to my sp_cleardb
that would go back and reset the identity columns
FYI
All of my tables use auto-incrementing identity fields with a seed of 1

1) I know how to do it in enterprise manager, but I need it in scripting
since I'll have to do it on hundreds of tables
2) I tried using alter table to drop the PK constraint, but that requires
knowing the pk constraint name, which is SQL generated and I won't know.

I think I got very close, but the code was just getting too big. I thought,
there must be an easier function to use, or a built in SP, or something?

Anyone know how to script this?
THanks in advance.
Josh

View 2 Replies View Related

Resetting Indentity Columns

Nov 15, 1999

I would like to reset the Identity column in a table so it starts at the begining. I am planning to clean out this table.

Thanks

Gary

View 1 Replies View Related

Stripping And Resetting Security

May 29, 2008

Question - if you had to completely strip all permissions from all databases in an instance and reset them, assuming you have metadata to support rebuilding the permissions, what steps would you follow? I can handle the iterating through each database, but at the database level, what steps would you take?

The reason I inquire on this is I currently have a job that I inherited that does just this. But it's buggy and was also written in for SQL Server 2000. With some of the changes in 2005, a few bugs have crept in, etc. And I would like to confirm my thoughts this. Or, if your opinion is why are you wasting your time on this? Then that's fine to and I'll review any constructive comments you may have.

View 4 Replies View Related

Report Schedule Resetting

Oct 30, 2007

Greetings,

I've run into an issue that's been driving me up a wall.

Running SQL Server 2005, two instances production and development, report server on each.
I have a multiple scheduled reports on each instance, and I've over wrote the report server subscription with a SQLAgent schedule.
For whatever reason the reports on the production instance keep having their schedule reset to the subscription when the report was first created.
The logs give me a warning that the schedule is changing or deleted but it's happening when no one is around.

Can anyone shed some light on this for me? or am I missing something really obvious here?

Thanks,

Erik

View 5 Replies View Related

SelectCommand Problem

Dec 7, 2006

for some reason the following code fails. I want to present all of the information of the CD (from table B)that inlcudes the song name the user types in the text box(table A).
Meaning the user types the name, it's located in table A, for each CD id in table A I want to present all the info from table B. Do I have to use DataRelation?:
private void Button1_Click(object sender, System.EventArgs e)
{
System.Data.SqlClient.SqlDataAdapter da=new SqlDataAdapter();
string str=TextBox1.Text;
 
System.Data.SqlClient.SqlParameter sparam=new SqlParameter("@song",SqlDbType.NVarChar);
sparam.Direction=ParameterDirection.Input;
sparam.Value=str;
da.SelectCommand=new SqlCommand();
da.SelectCommand.Connection=sqlConnection1;
da.SelectCommand.CommandText="CdInfoSP";
da.SelectCommand.CommandType=CommandType.StoredProcedure;
da.SelectCommand.Parameters.Add(sparam);
 
da.Fill(dataSet11,"CdInfoSP");
 
DataGrid1.DataSource=dataSet11;
 
DataGrid1.DataBind();
DataGrid1.Visible=true;
 
 
}
 
My Stored procedure is:
CREATE PROCEDURE dbo.CdInfoSP  (@song nvarchar)AS select cd_id,cd_name,year from song_cd_artist,cd_info where song_name like '%@song%' and cdofsong_id=cd_idGO
 
I hope someone can help me!
Thanks in advance!

View 1 Replies View Related

Sqldatasource.selectcommand?

Apr 27, 2007

Hello everyone,
I would like to know if there is a way to know if a sqldatasource.selectcommand returns tables or not? I'm trying to make a If statement so that if the selectcommand isn't returning anything it will disable a checkbox.
 
Thank you.

View 2 Replies View Related

Custom SelectCommand

Jun 19, 2007

 If I hard code the select statement everything works fine.
<asp:SqlDataSource ID="SqlDataSourceZip" runat="server" ConnectionString="<%$ ConnectionStrings:MyConnectionString %>"
SelectCommand="SELECT * FROM [Station] WHERE ([ZipCode] = '80523' OR [ZipCode] = '80521' OR [ZipCode] = '80553' OR [ZipCode] = '80522' OR [ZipCode] = '80526' OR [ZipCode] = '80527' OR [ZipCode] = '80525' OR [ZipCode] = '80524' OR [ZipCode] = '80547' OR [ZipCode] = '80535' OR [ZipCode] = '80538' OR [ZipCode] = '80551' OR [ZipCode] = '80549' OR [ZipCode] = '80550' OR [ZipCode] = '80546' OR [ZipCode] = '80539' OR [ZipCode] = '80512' OR [ZipCode] = '80537' OR [ZipCode] = '80541' OR [ZipCode] = '80650' OR [ZipCode] = '80515' OR [ZipCode] = '80513' OR [ZipCode] = '80610' OR [ZipCode] = '80534' OR [ZipCode] = '80536' OR [ZipCode] = '80634' OR [ZipCode] = '80543' OR [ZipCode] = '80532' OR [ZipCode] = '80638' OR [ZipCode] = '80615' OR [ZipCode] = '80646' OR [ZipCode] = '80648' OR [ZipCode] = '80612' OR [ZipCode] = '80631' OR [ZipCode] = '80528')"> </asp:SqlDataSource>
 Want to use a label control to return data, but can't find anything that works.
<asp:Label ID="zipLabel" runat="server"></asp:Label>
[ZipCode] = '80523' OR [ZipCode] = '80521' OR [ZipCode] = '80553' OR [ZipCode] = '80522' OR [ZipCode] = '80526' OR [ZipCode] = '80527' OR [ZipCode] = '80525' OR [ZipCode] = '80524' OR [ZipCode] = '80547' OR [ZipCode] = '80535' OR [ZipCode] = '80538' OR [ZipCode] = '80551' OR [ZipCode] = '80549' OR [ZipCode] = '80550' OR [ZipCode] = '80546' OR [ZipCode] = '80539' OR [ZipCode] = '80512' OR [ZipCode] = '80537' OR [ZipCode] = '80541' OR [ZipCode] = '80650' OR [ZipCode] = '80515' OR [ZipCode] = '80513' OR [ZipCode] = '80610' OR [ZipCode] = '80534' OR [ZipCode] = '80536' OR [ZipCode] = '80634' OR [ZipCode] = '80543' OR [ZipCode] = '80532' OR [ZipCode] = '80638' OR [ZipCode] = '80615' OR [ZipCode] = '80646' OR [ZipCode] = '80648' OR [ZipCode] = '80612' OR [ZipCode] = '80631' OR [ZipCode] = '80528'
something like this, but it don't work.
SelectCommand="SELECT * FROM [Station] WHERE (<%=zipLabel.Text%>)"> </asp:SqlDataSource>

View 3 Replies View Related

SqlDataSource - SelectCommand WHERE = A Value From

Nov 19, 2007

Hello, I'm new to ASP.NET (past 10 months) and am a little stuck. I will try to explain the best I can. I have a dropdown (ddNames) with a list of peoples names from my database and the value is their (staffID). When I select a name from the dropdown I want to get that Staff members details from my database. Everything works perfectly until I get to the
[[ WHERE staffID = "dropdown value??" ]] Can you help?

View 6 Replies View Related

SqlDataSource SelectCommand

Dec 12, 2007

I am trying to set a select command in a VB script which is activated by a button and to display the data in a gridview
The script code is 
SqlDataSource1.SelectCommand = "SELECT MemberID, Title, FirstName, LastName, EmailAddress, Password, DateTimeStamp, IPAddress, Description, Location, Position FROM Members, Careers WHERE " + Search.ToString() + " AND MemberID = CareerID"
and the grid view is<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"AutoGenerateColumns="False" DataKeyNames="MemberID" ataSourceID="SqlDataSource1"BorderWidth="0" BorderColor="White"EmptyDataText="There are no data records to display." GridLines="None" ShowHeader="False" >
 this works fine until the next page button is pressed then the message "No data records" comes up even though there are plenty of records still to come. It works fine if I set AllowPaging to be False.
Can anyone help?
 

View 4 Replies View Related

SelectCommand With Like Parameter

Jan 15, 2008

Hi, I try to do a simple search:
<SelectCommand="SELECT color FROM mytable where color LIKE @PARAMETER1 ">
<SelectParameters>
<asp:Parameter Name="PARAMETER1 " DefaultValue="%" Type="string"/>
</SelectParameters>
have a code with CASE
Dim pColor As String = "%"
Case "All" I put to parameter   "%"Case "Equals to" I put to parameter  Me.TextBoxColor.Text
Case "Begins with" I put to parameter  Me.TextBoxColor.Text + "%"
Case "Contains" I put to parameter  "%" + Me.TextBoxColor.Text + "%"
Me.SqlDataSource1.SelectParameters("PARAMETER1 ").DefaultValue = pColor
Everything work find except my "Equal to case"  and I try SELECT color FROM mytable where color LIKE blue and is don't work (return nothing)???  and I don't want %color% because is return me blue sky, not just blue.
Thank for help me

View 5 Replies View Related

The Sqldatasource Selectcommand...

Apr 12, 2008

Hi

Do you guy's know if there is an upper limit on the length of the string that can go into the selectcommand of the sqldatasource? I'm getting strange behavior from the sqldatasource. I'm dynamically generating select strings in the business layer and then programmatically using them in a sqldatasource up in the website. I sometimes get really large select statements (whole pages of joins) and was wondering if there was a character limit to the selectcommand property.

Nuwanda

View 4 Replies View Related

Sql Count And SelectCommand

May 14, 2008

Hi,
I use the Count function to get the total from my SelectCommand. However, I need to get my selectcommands dynamically, so is there a way of writing like this somehow:
"SELECT COUNT(1) FROM (MypagesSqlDataSource.SelectCommand)
Thanks in advance,
Pettrer

View 4 Replies View Related

SqlDataSouce.SelectCommand

Feb 3, 2006

How do you programmatically change the SQL select statement for the SelectCommand in a SqlDataSource?For instance, if I had two buttons on a page, and for one button, I'd like it to change the select command to be "SELECT * FROM authors WHERE au_id > 100". Then for the second button, I'd like it to show "SELECT * FROM authors WHERE au_lname like S%".Anybody know the code to do this? I was trying to type the code, but the intellisense didn't give me any options to pick from after I typed SqlDataSouce1.SelectCommand.

View 3 Replies View Related

Please Help With Sqldatasource Selectcommand

May 25, 2006

Greetings all,
I am new to ASP, .NET, and VWD2005. My experience lies primarily with PHP.
I was impressed with how simple it was to create a datagrid view of a table in VWD, however, now I'm stuck and need some assistance.
I have an Access database, and have configured an SQL Data Source to it. (forgive me if my terminology is bad)
The code is:
<asp:SqlDataSource ID="SqlDataSource1" runat="server"    ConnectionString="<%$ ConnectionStrings:ConnectionString %>"   ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>"    SelectCommand="SELECT phones.FirstName, phones.LastName, phones.Phone, Departments.DepartmentName      FROM (Departments INNER JOIN phones ON Departments.DEPT_ID = phones.DEPTID)      WHERE (phones.FirstName BETWEEN 'A' AND 'AZZZ')      ORDER BY phones.FirstName"></asp:SqlDataSource>
It works fine and returns all the names/phone numbers of people beginning with 'A' as anticipated.
My original intent was to create a sting variable "strQry" which contained the actualy Select statement above. The strQry would be programatically created to alter the WHERE statement accordingly for B,C,D,E - Z. My code would then be
<asp:SqlDataSource ID="SqlDataSource1" runat="server"    ConnectionString="<%$ ConnectionStrings:ConnectionString %>"   ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>"    SelectCommand=strQry></asp:SqlDataSource>
This did not work. What am I doing wrong?
I also tried programatically testing the condition of the desired letter (A-Z) and having it use a select case statement to call multiple occurences of the asp:SqlDataSource control. The problem I ran into there is that the ID "SqlDataSource1" is already in use on my subsequent occurences. (regardless, this would produce a huge bloated section of code having 26 instances of the control)
I need some help please. Any advice would be greatly appreciated.
 
 

View 5 Replies View Related

Resetting Key Column Numeration From SQL Tables

May 1, 2007

I used a lot of fictitious data in order to test the code of my web site. But I noticed that when I deleted all fictitious data from the tables, the primary key columns keep creating automatically numbers that are above the last one before all data was erased instead of starting again from number 1. How do I reset this automatic numeration in order to restart from 1 again ?

View 3 Replies View Related

Resetting Value Of Identity Field After A Delete

Mar 29, 2000

Can anyone tell me of a way to reset the value of an Identity field back to its seed value after all the rows in a given table have been deleted and I try to re-populate it? There are foreign key relationships so I cannot just drop and recreate the table, and I really need to address this issue from within sql, rather than from the application.

Thanks, any and all guidance would be great :)

View 4 Replies View Related







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