DataSource Controls :: Unable To Put Space To Dynamic Sql Query?
Jan 20, 2010
i have a query like this and its running correctly
SELECT CAST(REPLACE(LTRIM(RTRIM(SUBSTRING(P.Telephone, 2, LEN(P.Telephone)))), ' ', '') AS BIGINT)
FROM P INNER JOIN PCommunication ON P.ID = PCommunication.ID
WHERE P.Telephone IS NOT NULL AND CAST(REPLACE(LTRIM(RTRIM(SUBSTRING(P.Telephone, 2, LEN(P.Telephone)))), ' ', '') AS BIGINT) > 5000000000
AND PCommunication.TypesID = '7667d187-5fe1-4aaf-9e31-79761561da58'
i am trying to use it with dynamic query like this but its not working
@query = 'SELECT CAST(REPLACE(LTRIM(RTRIM(SUBSTRING(P.Telephone, 2, LEN(P.Telephone)))), ''' ''', '''''') AS BIGINT)
View 9 Replies
Similar Messages:
Mar 14, 2010
I creat a Family Website and i use Dataset to get Family members from sql databace.
In my databace i have MemberID, Name, MiddleName and Last Name.
I want also return the Member FullName and i use this Query to return the members from database table:
SELECT MemberID, ParentID, Name, MiddleName, LastName, Name + MiddleName + LastName AS FullName
when we have Name="Jon" MiddleName="" Lastname="Smith" it return JohnSmith
my only problem is how can i get space between the Name MiddleName And Last name like "Jon Smith"
View 2 Replies
Jan 25, 2010
I have a query which is returning records like below which returns a list of tasks with a corresponding task type. there is a task table (wh_task) and a task type table (wh_task_type). What i want to achieve is a count of all the tickets per ticket type. So at the end of the query i will have a total for Administration / Maintenance tasks (1) and a total for Routine Maintenance Tasks (3). ** and all the other types *
There are many different types of task type so I dont want to have to hard code it. Can count all the occurencies of the different ticket types.
Task Name
Task Type
Date Completed
SBS Server C drive running out of space
Administration / Maintenance
16/07/2007 16:03:34
Patching Server(s).
Routine Maintenance
08/01/2009 06:51:56
Patching Server(s).
Routine Maintenance
11/02/2009 10:06:06
Patching Server(s).
Routine Maintenance
04/05/2009 06:53:24
I can also get wh_task_type_id.
Here is my SQL:
[Code]....
View 8 Replies
Aug 22, 2010
1. I have a GridView on my page and it uses sqldatasource with parameterized query. What I want to do is, on page load (where nothing has been selected so no parameter supplied), I want it to query everything (something like SELECT * FROM [this_table]) but since my SelectCommand is something like
SELECT * FROM [this_table] WHERE [this_column] = @someParameters AND [that_column] = @someParameters.
Can I play around with default value to achieve something like that but how ? Now, when the page loads, it doesn't show anything (No Gridview).
2. On my page, I made something like (username, gender, address, and more) and one single search button. That means, no single control enable auto postback. What I am trying to accomplish is building dynamic query
(if username specifed -> SELECT * FROM [this_table] WHERE [username] LIKE @username).
If both username and gender are specified (SELECT * FROM [this_table] WHERE [username] LIKE @username AND [gender] = @gender) and you know the rest. How can I do this using GridView and SqlDataSource ? To my knowledge, I can only specify one SELECT statement in a sqldatasource.
View 11 Replies
Apr 19, 2010
I'm passing on two Querystrings "ddl2" and "ddl3" onto an aspx page. At this page I'm running a SQL Query which has a WHERE clause in it that SHOULD use both the querystrings but only one of the two QS works at a time. When I use only "ddl2" OR only "dd3" in the WHERE clause the result is shown but not when both the Querystrings are used.
Below is the link to the page i get where I use the two QS's.
~/Option1_result.aspx?ddl2=722&%20ddl3=CA
Below is my SQL code:
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:Inventory_DBConnectionString3 %>"
SelectCommand="SELECT * FROM [CA] WHERE (([LATA] = @LATA) AND ([State] = @State))">
<SelectParameters>
<asp:QueryStringParameter Name="LATA" QueryStringField="ddl2" Type="Int16" />
<asp:QueryStringParameter Name="State" QueryStringField="ddl3" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
View 2 Replies
Mar 3, 2010
I am SELECTING two columns:
SELECT ([FirstName] + [LastName]) AS [FullName], UserID WHERE CustomerID = @CustomerID
I would just like to know if there is a way to add a space between the two columns in the select statement.
This SqlDataSource Binds to a DropDownList so TextValue = "FullName" and DataValue = "UserId"
but of course, the way it is now the fullname is all one word.
View 3 Replies
Jan 8, 2010
I am trying to replace all null value with space for all columns in a table.
(note: just we have to pass parameter table name "XYZ" result will come aotumaticly, we dont need to bother about column name)
i have done it through C# application. but love to do it through Sqlserver only like using storeprocedure, function.
my C# code is like that
[code]....
View 6 Replies
Dec 25, 2010
i want to add leading space in dropdown list after binding from DB.
for that i used leftpad method but not working.
code are as below
[Code]....
View 3 Replies
Aug 22, 2010
I've been trying to insert new values while I create a new user with a createuserwizard, but I've been getting this error over and over again:
"insufficient result space to convert uniqueidentifier value to char"
The code that does it is the following:
[Code]....
But when I debug, the error is thrown before reaching the previous code, so I suppose the error is in the SqlDataSource, look:
<asp:SqlDataSource ID="InsertExtraInfo" runat="server" ConnectionString="<%$ ConnectionStrings:DefaultConnection %>"
InsertCommand="INSERT INTO [User_Personal] ([UserId], [Gender], [ToGender], [StateName], [CityName],
[code]...
View 1 Replies
Jan 15, 2010
[code]...
This query works perfectly on the query analyser.
But when configuring the Table adapter ,I try executing the query and i get 0 rows affected.
What could I be getting wrong in this case.
NB:Existing GalleryID has been supplied.
View 1 Replies
May 17, 2010
By right clicking on my database i created a query in server explorer. But where are this query stored can't find them back. I should aspect that their is a folder query's like there is a folder tables but this isn't the case.
View 10 Replies
Mar 10, 2010
select Groupid,GroupName,onorusername from palgroup where groupid in (select distinct Groupid
View 5 Replies
Jan 21, 2010
I've got a query such as
Dim MediaQuery =
From m
In dB.DOWNLOADS _Where m.ID = id _Select
which returns a record from the database. One of the fields in the record is a FK to another table. I need to read this value to be able to set a dropdown based on the ID but I can't work out how to access it. For a standard record I can just do the following txtTitle.Text = MediaQuery.FirstOrDefault().TITLE
However with the foreign key it doesn't work like that. I've tried drpGroup.SelectedIndex = MediaQuery.FirstOrDefault().DOWNLOAD_GROUPS.ID where DOWNLOAD_GROUPS is the FK field but it returns Object reference not set to an instance of an object. If you're simply wanting to read some values from a single db record in the entitiy framework and one is a foreign key how should I go about getting the value?
View 2 Replies
Jul 6, 2010
I have a form in a page and a panel inside the form.The panel gets loaded with dynamic controls like radio button and text boxes.
User is allowed to choose any radio option and enter any value in the textbox beside it and then goes for submit button to move to next stage.
Problem Descritopn:
I load the controls in the panel based on the index of a combo control on the same form.it is done in selectedIndexChanged - This is working fine.
When i go for the submit button and ask for the textbox control, it says "object reference not set to instance of object", denoting that instance is not available. Moreover the panel control list gets empty automatically.
View 6 Replies
Apr 20, 2010
I've added the Dynamic.cs file to my project and have set it's Build Action = Compile in order to get the System.Linq.Dynamic namespace.
However, when I try to use any of the new code I am getting an ambiguous call error; see below.
[Code]....
View 2 Replies
Sep 22, 2010
i'm using asp.net 3.5 and what im trying to do is create the dropdownlist item dynamically base on value in each datarow, then user select from dropdownlist and click button to postback, when postback system should be able to know what value has been selected by user. the problem with following code is during postback, event of "OnItem_Created" get fired and e.Item.DataItem return null, therefore the dropdownlist will not get populated with the items and that caused the dropdownlist unable to return value selected by user. am i missing anything? is "OnItemCreated" the best place to dynamic create the dropdownlist item?
[Code]....
View 2 Replies
Sep 27, 2010
I am unable to create dynamic menu from database. I have made two tables for this work.First table is Menu which stores menu id and its relevant name.
MId Text
------------
1 File
2 Edit
3 View
..
..
Second table is subMenu which stores submenus which will be linked to the menu table with menu id.
SId Text MID
-------------------
1 New 1
2 Open 1
3 Save 1
4 Cut 2
5 Copy 2
the menu should be created dynamically from the database, each menu should be displayed in single row
when we click on a menu the submenus are displayed in rows that in expand & contrast form
how to design & develope this page
View 3 Replies
Mar 3, 2010
I wanna join all the field as a new col.
but how can i ignore the empty field because i always join the field and separate by space like the following.
select (field_1+' '+field_2+' '+field_3) as new_col from TABLEA
but if the field is empty, then there is the double space
how can i ensure all the space is one space only.
View 2 Replies
Aug 6, 2010
I've got an issue with the postback property. I have a chart (Code below) which has two series pulled from a datasource.
Both series display fine but I've enabled the bars in the chart to respond to the click event and when items from the first series is selected, everything works fine. However, I try to pull the x value for the second series, which is supposed to be a date, but all I get is an interger.
[Code]....
C# Code...
[Code]....
View 1 Replies
Jun 2, 2010
I have a user control (ascx) which contains a control (hidden field). In the page_load event of ascx, i have the below code:
HyperLink.Attributes.Add("onclick", "JavaScript:return AccessControl('" + hdnField.UniqueID + "');");
Note: The hidden field resides in .ascx file.
I want to access this hidden field at runtime and i have the below javascript function in aspx page that loads the usercontrol.
function AccessControl(hdnFieldId)
{
var ctrl = document.getElementById(hdnFieldId);
alert(ctrl);
I am getting 'null' value in the alert. I tried using 'ClientID' and 'this' instead of 'UniqueId'. I am wondering why this is not working. I am using .net 2.0.
View 1 Replies
Feb 10, 2011
i'm writing a stored proc and if a field i return is longer then 200 characters, i want to truncate, find the last space, remove any characters after that space, then add some full stopseg:
INSERT INTO @rec(articleid, abstract)
SELECT a.id,
CASE
[code]...
View 4 Replies
Jul 1, 2010
I want to create a search form for a table that has many columns. According to input criteria the query will have a where with conditions related to the columns selected or NONE. How can I create a dynamic query according to selected conditions ? is there an example on the net that I can use?
View 2 Replies
May 5, 2010
How to replace a character in a String to space or white-space?
View 3 Replies
Apr 21, 2010
I am using Querystring "ddl4" to pass on value of a drop down list to the next page where I am using that value in the WHERE clause of a SQL command. I also need to check whether ddl4 is blank or not which I do using If Else in SQL command. I am not able to run the query where the Querystring ddl4 IS NULL
This is the sample link with the Querystring ddl4 carrying a blank value:
[code]....
View 2 Replies
Jan 24, 2011
I have a problem with DataSet.GetXml() in ASP.NET 4.0:
First I populate the dataset with some tables.
Then I run the .GetXml() method on the dataset and some XML is returned. The output of this method is not want I want it to be, however.
The desired result is this:
[code]....
How do I stop this from happening? I mean, how do I stop the cell from being included at all?
In ASP.NET 1.1 the same code is used and the desired output is returned. This means that it is probably some new thing in 4.0 that I have to switch on/off. But what?
View 1 Replies