Syntax Problem For WHERE Part Of My SqlDataSource SelectCommand
Jun 6, 2008
I am setting the SelectCommand of the SqlDataSource in my page_load. This is the WHERE part of my SelectCommand:
WHERE ProductName LIKE '%' ? '%' OR ProductRef LIKE '%' ? '%'
The above uses two select parameters. But the two select parameters will have the same value. So is it possible to re-write my select command so it just uses one parameter? I have tried the following, but this doesn't work.
WHERE (ProductName OR ProductRef) LIKE '%' ? '%'
Is there similar syntax I could use that works?
View 2 Replies
ADVERTISEMENT
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
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
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
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
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
Jun 27, 2006
Hallo,Why doesnt SelectCommand have problems with angle brackates if I place = insted of <> then it works fine??? Also do I have to convert a Session datetime dtdate like this to select from SQL2000?SelectCommand = "SELECT (SELECT PICTUREID FROM PICTURE WHERE TYPE = 1 AND HOTELID = HOTEL.HOTELID) AS PictureID, dbo.Hotel.HotelID, dbo.Hotel.Name AS HName, dbo.Hotel.Star, dbo.Loc.GLoc, dbo.Loc.NameCZ, dbo.Loc.NameCZ2, MIN(dbo.HSRSeason.Price) AS LowestPrice FROM dbo.Hotel INNER JOIN dbo.HSR ON dbo.Hotel.HotelID = dbo.HSR.HotelID INNER JOIN dbo.HSRSeason ON dbo.HSR.HSRID = dbo.HSRSeason.HSRID INNER JOIN dbo.Room ON dbo.HSR.RoomID = dbo.Room.RoomID INNER JOIN dbo.HSeason ON dbo.Hotel.HotelID = dbo.HSeason.HotelID INNER JOIN dbo.Loc ON dbo.Hotel.LocID = dbo.Loc.LocID WHERE (dbo.Room.Name <> 'Extra Bed') AND (dbo.HSeason.[From] <= CONVERT(DATETIME, '" + @dtdate1 + "', 104)) AND (dbo.HSeason.[To] >= CONVERT(DATETIME, '" + @dtdate1 + "', 104)) GROUP BY dbo.Hotel.HotelID, dbo.Hotel.Name, dbo.Hotel.Star, dbo.Loc.GLoc, dbo.Loc.NameCZ, dbo.Loc.NameCZ2, dbo.Hotel.Com ORDER BY Com DESC"
View 4 Replies
View Related
Nov 17, 2006
This is my SQLDataSource for my gridview
<asp:SQLDataSource ConnectionString="<%$ ConnectionStrings:Pubs %>" id="sqlProducts" Runat="Server" SelectCommand=' "Select * from adressen INNER JOIN Adressoort ON adressen.AD_ID = Adressoort.AD_ID where " & lblsql.Text ' ></asp:SQLDataSource>
the label is something like : adressoort.AD_soort = '3' or adressoort.AD_soort = '1'
I keep on getting the error sever tag not well formed
View 3 Replies
View Related
Nov 10, 2007
I'm try to achieve the following ;
<asp:SqlDataSource ID="CardDataSource" runat="server" ConnectionString = "my connection SelectCommand = "String.Format("Select * from cards where active not like '0' or active is NULL and (card like ' {0}%' or card like '{0}%')", Request.QueryString("db"))" />
I'm trying to pass a value into my query from the sqldatasource, but I'm having trouble properly using the string. This code used to be in a vb code, but theres a considerable performance difference when I have it load from my vb file and when I front load it here.
Anyone know what i would have to add or remove to make the above script work? Do I have my single/double quotes mixed up?
View 5 Replies
View Related
Mar 6, 2008
Hi,
I would like to set the selectcommand property of the sqldatasource at runtime.
how to do that?
can somebody help me out?
View 1 Replies
View Related
Jan 16, 2006
Good morning.I'm writing an application that allows users to generate Personal Leave requests and route them to their managers.I'm using the integrated Windows Authentication, so I'm able to get the user's username from HttpContext.Current.User.Identity.Name.How do I dynamically generate the SelectCommand? Right now, I do:Dim strQuery As String = "SELECT * FROM [tblPLRequest] WHERE employee = '" & strUsername & "'"to get the query I want, but when I set my SelectCommand to that, it thinks it's a stored procedure (and can't find it).Am I going about this in the completely wrong way?Thanks.
View 3 Replies
View Related
Feb 28, 2007
Hi folks,I'm having problems using the SqlDataSource to return certain values from a SQL database. I have two DropDownLists. When the first DDL's selected index is changed, I need to take the value (an int id) from the field, use the value to look up a string in a different colum in the table for that record id, which should then be used to automatically select a value from the second DDL. I think my problem is I'm not sure how to get the SelectCommand to actually return the value, let alone in string form!Here is my code:{ string selectedProject = ProjectDDL.SelectedValue; SqlDataSource temp = new SqlDataSource(); temp.ConnectionString = rootWebConfig.ConnectionStrings.ConnectionStrings["DBConnectionString"].ToString(); temp.SelectParameters.Add("id", selectedProject); temp.SelectCommand = "SELECT [username] FROM dbo.projects WHERE id = @id"; //temp.Select(); ? //AssigneeField.SelectedValue = string returned from Select Statement!} I'd appreciate it if somone could point me in the right direction? Thanks,Ally
View 2 Replies
View Related
Mar 12, 2008
Hi Everyone,
I set the session("MyTable") with the user's name as contents when the user logs in, then I copy a new table name with session("MyTable") , I set PK and this all works, but I can't seem to figure out how to use the session var as table name SQLDataSource Selectcommand? I try a bunch of different stuff, putting it into a key in the web.config. Seems like this should be a piece of cake.
Im getting ~ "Session variable is not a valid datasource item" etc. Below is one of the things I have tried.<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:Connectio String %>" SelectCommand="Select * From [" + Session("MyTable") + "] Where ID = @ID">
TIA
Cebo
View 2 Replies
View Related
May 7, 2007
Can you dynamically set the name of the table in the SelectCommand section of the SqlDataSource? (If it is relevant, I code in C#)
For example,
<asp:SqlDataSource runat="server" ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:Test-MySQL %>" ProviderName="<%$ ConnectionStrings:Test-MySQL.ProviderName %>" SelectCommand="SELECT * FROM TestTable">
I would like to replace 'TestTable' with the name of a table that is extracted from a string array in the code-behind.
Appreciatively,Peter
View 4 Replies
View Related
Feb 24, 2008
Hi all,
I've been trying to rack my brains over this one; When I use this select statement in SqlDataAdapter, it runs fine; it takes about 4 to 5 seconds to run. In SqlDataSource, its very erratic; taking between 8 to 71 seconds to run. I've finally narrowed down the issue to something that resolves the symptoms to something in my query;
SELECT f.UnitID, f.FacilityName, SUM(CASE WHEN t .sData_Type = 'CLINICAL' THEN t .nWrite_Off_Amt ELSE 0 END) AS Sum_Clinical, SUM(CASE WHEN t .sData_Type = 'OTHERS' THEN t .nWrite_Off_Amt ELSE 0 END) AS Sum_Others, SUM(t.nWrite_Off_Amt) AS Sum_Total, SUM(t.nCashAmount) AS Sum_Cash, t.iYearFROM t LEFT OUTER JOIN d ON t.sUnitID = d.sUnitID AND t.sPat_Num = d.sPat_Num AND t.iMonth = d.iMonth AND t.iYear = d.iYear LEFT OUTER JOIN tblFac AS f ON t.sUnitID = f.UnitID_1WHERE (t.iYear = @year) AND (t.iMonth = @month) AND (@UnitID IN ('08948', RIGHT('0' + f.Division, 5)))GROUP BY f.UnitID, t.iYear, f.FacilityName, f.Division
If I change my WHERE clause to the following
WHERE (@year = t.iYear) AND (@month = t.iMonth) AND (@UnitID IN ('08948', RIGHT('0' + f.Division, 5)))
performance is MUCH better. How could such a little change make such a big difference in speed?
Thanks.
-e
View 3 Replies
View Related
Sep 15, 2007
Hey,I've inherited a project from my office and am stuck.I'm trying to take input from multiple souces (DropDownLists, TextBoxes, etc) and depending on which ones are used, update a SELECT string with additional AND statements. <script language=VB runat=server>
Dim resultsql As String
Public Sub Button_Click(ByVal client As String, ByVal state As String)
Dim dv As String
resultsql = resultsql & "SELECT ClientName, Address1, City, State FROM tblClient"
dv &= ""
If (StrComp(client, dv) <> 0) Then
resultsql &= "AND ClientName = " & client
End If
If (StrComp(state, dv) <> 0) Then
resultsql &= "AND State = " & state
End If
resultsql &= " ORDER BY ClientName ASC"
End Sub
</script>Now when I got to display the results of this new string in a GridView I am recieving errors trying to pass my variable "resultsql" into SelectCommand. <asp:GridView ID="Results" runat="server" AutoGenerateColumns="False" DataKeyNames="ClientNumber"
DataSourceID="SqlDataSource3">
<Columns>
<asp:BoundField DataField="ClientName" HeaderText="ClientName" SortExpression="ClientName" />
<asp:BoundField DataField="Address1" HeaderText="Address1" SortExpression="Address1" />
<asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />
<asp:BoundField DataField="State" HeaderText="State" SortExpression="State" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:SQLConnectionString %>"
SelectCommand=resultsql> </asp:SqlDataSource> I've scoured the web without any success. Any suggestions are appreciated.
View 7 Replies
View Related
Dec 12, 2006
Hi all
I have a cms-page where i want to display various entry-categories like news etc....I want to define which kind of entries should be shown by a parameter in the URL (e.g. cms.aspx?category=news). So far everything is OK.
To display the entries actually I'm using the following SqlDataSource:
<asp:SqlDataSource ID="SqlDataSourceCMS" runat="server" ConnectionString="......."SelectCommand="SELECT * FROM [cms] where category = news"></asp:SqlDataSource>
What i need, is to set the category which i want to show dinamically, like with a variable.
Does anybody know how i can set something like a variable in the SelectCommand property of the SqlDataSource?
View 1 Replies
View Related
Sep 18, 2007
Although writing a parameterized SQL statement has been simplified using the asp:parameter options, it still may benefit to use the old fashioned method of writing a sql statement using an input string. I have noticed this for wanting to make a parameter to select which table I want to pull from. Here is some code I wrote to pull information from a database based on input from a search box and write it to a gridview.
Partial Class Private_SearchResultsInherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim Table As String
Dim SearchString As StringSearchString = Request.QueryString("SearchString")
Table = Request.QueryString("Table")
If Len(Trim(SearchString)) > 0 ThenSelect Case Table
Case "Plant"
SqlDataSource1.SelectCommand = "SELECT PlantName as 'Plant',PlantAddr as 'Address',PlantCity as 'City',PlantState as 'State',PlantCountry as 'Country',PlantZip as 'ZIP' FROM Plant WHERE PlantName LIKE '%" & SearchString & "%' OR PlantCity LIKE '%" & SearchString & "%' OR PlantState LIKE '%" & SearchString & "%' OR PlantCountry LIKE '%" & SearchString & "%' OR PlantZip LIKE '%" & SearchString & "%' ORDER BY PlantName"
Case "Contacts"
SqlDataSource1.SelectCommand = "SELECT ContactPosition as'Position',ContactTitle as 'Title',ContactLast as 'Last Name',ContactFirst as 'First Name',ContactPhone as 'Phone No' FROM Contacts WHERE ContactLast LIKE '%" & SearchString & "%' OR ContactFirst LIKE '%" & SearchString & "%' OR ContactPosition LIKE '%" & SearchString & "%' OR ContactPhone LIKE '%" & SearchString & "%' OR ContactTitle LIKE '%" & SearchString & "%' ORDER BY ContactLast"
Case "Events"
SqlDataSource1.SelectCommand = "SELECT EventName as 'Event',CONVERT(varchar,EventStartDate,101) as'Start Date',CONVERT(varchar,EventEndDate,101) as 'End Date',EventNotes as 'Notes',EventNoAttendees as 'Attendees',EventType as 'Event Type' FROM Events WHERE EventName LIKE '%" & SearchString & "%' OR EventStartDate LIKE '%" & SearchString & "%' OR EventEndDate LIKE '%" & SearchString & "%' OR EventNotes LIKE '%" & SearchString & "%' OR EventNoAttendees LIKE '%" & SearchString & "%' OR EventType LIKE '%" & SearchString & "%' ORDER BY EventName"
Case ""
Label1.Text = "Nothing Selected in Drop Down Box"
End Select
Else
Label1.Text = "No Search Parameters Entered"
End If
GridView1.DataBind()End Sub
End Class
Here is also my code to the front end of the page...
<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="SearchResults.aspx.vb" Inherits="Private_SearchResults" title="Search Results" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<br />
<strong><span style="font-family: Tahoma">Search Results<br />
<br /></span></strong>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
<asp:Label ID="Label1" runat="server" Font-Names="Tahoma" Font-Size="10pt"></asp:Label><br />
<asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None" DataSourceID="SqlDataSource1" Width="1020px">
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" Font-Names="tahoma" Font-Size="Small" />
<EditRowStyle BackColor="#999999" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="Indigo" Font-Bold="True" ForeColor="White" Font-Names="tahoma" Font-Size="Small" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" /></asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:CRMConnectionString %>"></asp:SqlDataSource>
</asp:Content>
View 2 Replies
View Related
Jan 29, 2015
This query is the first time I am using the Unpivot syntax and I am coming across a problem. When I try to unpivot my data, I get the following statement:
"Msg 4104, Level 16, State 1, Line 2
The multi-part identifier "Table3.DocketId" could not be bound."
What is the cause of this issue?
Select
Table3.DocketId,
UP.AssignmentType,
Up.AssignedStaff
From
(
Select distinct
Table2.DocketId,
[Code] ....
View 3 Replies
View Related
May 25, 2006
Hi,
I have a question re sqldatasource syntax. I have the following code in the .vb file (I'm using VWD Express and VB):
If slag = "a" Then
Kptyp1HiddenField.Value = 40
Kptyp2HiddenField.Value = 50
End If
If slag = "b" Then
Kptyp1HiddenField.Value = 30
Kptyp2HiddenField.Value = 30
End If
...And in my .aspx file:
<asp:DropDownList ID="KpnrDropDownList" runat="server" Style="z-index: 102; left: 640px;
position: absolute; top: 120px" BackColor="WhiteSmoke" Width="256px" DataSourceID="kpSqlDataSource"
DataTextField="kpnamn" DataValueField="kpnr">
</asp:DropDownList>
<asp:SqlDataSource ID="kpSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:dbConnectionString %>"
SelectCommand="SELECT [kpnr], CONVERT(varchar(4),[kpnr]) + ' (' + [kpnamn] + ')' As kpnamn FROM [kpstandard] WHERE (([kptyp] = @kptyp1) OR ([kptyp] = @kptyp2)) ORDER BY [kpnr]">
<SelectParameters>
<asp:ControlParameter ControlID="Kptyp1HiddenField" DefaultValue="00" Name="kptyp1" PropertyName="Value" Type="Int16" />
<asp:ControlParameter ControlID="Kptyp2HiddenField" DefaultValue="90" Name="kptyp2" PropertyName="Value" Type="Int16" />
</SelectParameters>
</asp:SqlDataSource>
+ two hidden fields.
What I'd like to do is to get the two variables Kptyp1 and kptyp2 directly from the .vb file, either to the SELECT statement, or at least to the controlparameter code, instead of having to go through two hidden fields.
How do I do this?
Thanks in advance,
Pettrer
View 1 Replies
View Related
Mar 21, 2006
Can anyone help me out with using parameters in my SqlDataSource?
I have my UpdateCommand set as follows:
UpdateCommand="UPDATE Custom_ContainerRequest_ESTWEIGHTS SET WEIGHTRANGES = @WEIGHTRANGES WHERE ESTWEIGHTS_ID = @original_ESTWEIGHTS_ID"
<UpdateParameters> <asp:Parameter Name="WEIGHTRANGES" Type="String" /> <asp:Parameter Name="original_ESTWEIGHTS_ID" Type="Int32" /></UpdateParameters>
And the application is just hanging when I run it. (No error message.)
If, however, I hardcode the values instead of using parameters, it works just fine everytime.
UpdateCommand="UPDATE Custom_ContainerRequest_ESTWEIGHTS SET WEIGHTRANGES = 'test' WHERE ESTWEIGHTS_ID = 1"
So I don't know if it's a single-quote issue, or if there's some other syntax I need, or what. One last note is that this is a DB2 database I'm using. But I'm sure that my connection is valid because I can read and update data...only not using parameters.
Any help is greatly appreciated.
Thanks,Billy
View 2 Replies
View Related
Jan 23, 2007
Hi
I need to create an sqlDataSource that filters a table based on the users ID – in other words, I have a table with a list of users, and when a logged in user loads the page, the results should only show records with their user name.
How would I do this?
Thanks for any help in advanceRichard
View 3 Replies
View Related
May 3, 2007
Hi,
I need to UPDATE the IP Address of a newly created user into a table (the value is currently set to default - " Not Available"), and I really dont know the syntax required to do this. So far I've derived all the variables needed using the following code:
protected void ContinueButton_Click(object sender, EventArgs e)
{
//Get the ip address and put it into the customer table - (the instance of this user now exists)
MembershipUser _membershipUser = Membership.GetUser();
Guid UserId = (Guid)_membershipUser.ProviderUserKey;<--------------------------------------------------------------I can see the UserId here if I pause the prog
SqlDataSource customerDataSource = new SqlDataSource();
customerDataSource.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();
customerDataSource.UpdateParameters.Add("IPAddress", Request.UserHostAddress.ToString());<---------------------------------------I can see the IPAddress here
customerDataSource.UpdateCommandType = SqlDataSourceCommandType.Text;
what next
I've not got a clue as to what to write next. There is a try / catch statement after this using :
rowsAffected = customerDataSource.Update();
which remains at 0 no matter what I try.
Any help greatly appreciated.
View 15 Replies
View Related
Oct 29, 2007
I have SSRS 2005 SP2 configured to work in Sharepoint integration. Everything works fine except that I am not able to programmatically change any property of report viewer web part (instance) that I have added on on home page of my sharepoint site.
I can do same thing via sharepoint UI but not through program. When my programs runs it fetches all web parts been added on home page, then I need to iterate through each one and find report viewer web part.
While iterating, as soon as I arrive to report viewer web part it is named as "Error web part" with error message as
"Windows SharePoint Services cannot deserialize the Web Part. Check the format of the properties and try again"
If someone has a solution, please respond at your earlist.
Thanks
Shankar
View 1 Replies
View Related
Dec 7, 2007
I have a table with a column named measurement decimal(18,1). If the value is 2.0, I want the stored proc to return 2 but if the value is 2.5 I want the stored proc to return 2.5. So if the value after the decimal point is 0, I only want the stored proc to return the integer portion. Is there a sql function that I can use to determine what the fraction part of the decimal value is? In c#, I can use
dr["measurement "].ToString().Split(".".ToCharArray())[1] to see what the value after the decimal is.
View 3 Replies
View Related
Jan 28, 2015
I have made the following Scalar-valued function:
CREATE FUNCTION [dbo].[TimeCalc]
(
@OriginalTime AS INTEGER
, @TenthsOrHundredths AS INTEGER -- code 2: 1/10, code 4: 1/100
)
RETURNS NVARCHAR(8)
[Code] ....
What it does is convert numbers to times
E.g.: 81230 gets divided by 10 (times in seconds: 8123). This 1 1 full minute, and the remainder = 2123 making it 1.21.23 mins)
So far so good (function works perfectly)
My question: sometimes times are in 1/100 (like above sample), sometimes in 1/10.
This means that, e.g. with a time like 3.23.40 the last zero must be deleted.
My thoughts are to use the results from the Return Case part, and as the code = 4: leave it as it is,
is the code 2 the use LEFT(... result Return Case ..., Len(..result Return Case.. - 1))
There are 5 codes: 0 1 2 3 and 4
View 9 Replies
View Related
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
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
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
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
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
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
Sep 6, 2007
I'm trying to create a simple search against a SQL Database. I setup a TextBox and a GridView, I simply need the contents of the textbox to be used on databind() in my SQL select statement. Seems like it should be a simple thing to do, any guidance is appreciated! Here is my code:
<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" Title="IP Tracker - Search" EnableSessionState="True" %>
<script runat=server>Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Search_GridView.DataBind()
End Sub
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="MasterContent" Runat="Server">
<br />
<strong>Search for IP</strong><br />
<br />
<input id="SearchBox" type="text" /><br />
<asp:Button ID="Button1" runat="server" Text="Please Work..." onclick="Button1_Click"/><br />
<br />
<asp:GridView ID="Search_GridView" runat="server" DataSourceID="SqlDataSource1" EmptyDataText="No Records Match">
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:IP_TrackerConnectionString %>"
SelectCommand="SELECT * FROM [AddressTable] WHERE ([IPAddress] LIKE '%' + SearchBox.text + '%')">
<SelectParameters>
<asp:FormParameter FormField="SearchBox" Name="IPAddress" Type="String" />
</SelectParameters></asp:SqlDataSource>
</asp:Content>
View 7 Replies
View Related