DataSource Controls :: SQL Query With IF And Select

Feb 18, 2010

SQL Query with IF and Select

View 2 Replies


Similar Messages:

DataSource Controls :: Sql Select Query Where Date

Apr 13, 2010

in DataBase Attendancedate is save in this format 4/5/2010 4:16:28 PM ..i want to query like this select * from EmployeeAttendance where Attendancedate='4/5/2010' but this giv error

View 5 Replies

DataSource Controls :: Multiple Like Statements In One Select Query

Mar 15, 2010

I need to write a select query where it will be doing "like" on one column with multiple strings.

Eg : Select * from tblCity where city like '%ABC%' and city like '%XYZ%'

I have set of strings.

View 5 Replies

DataSource Controls :: SQL Select Statement - Values To Appear In Same Query

Feb 15, 2010

I am having difficulty selecting data from 2 tables that do no share a primary key value. For instance, I have an actual table, a forecast table, and a GLText table. I may have an actual value but not a forecast value but I need them to appear in the same Query (like the query results shown below). I can get all values to appear in each table but have been unsuccessful in getting all values from both tables.

View 5 Replies

DataSource Controls :: Include An Alias In Select Query?

Jun 22, 2010

I have an application that I am developing using ASP.Net with visual basic code. I have a table called "Customers" that contains 3 fields. The name of each field is "Name", "LocationA", and "LocationB". I want to code a select query that list two columns. The first column should contain the field "Name". I want the second column to contain the value in the field "LocationB" if "LocationB" is not null, else I want the second column to contain the value in the field "LocationA".

View 4 Replies

DataSource Controls :: Select Query / Not Filtering Data From Database?

Mar 19, 2010

i have used one query like this

Select skillReq from tblPostJobs where SkillReq like '%Silverlight 2.0%'

it is working fine. But while giving

Select skillReq from tblPostJobs where SkillReq like '%Silverlight 2.0,C#%'

It is not filtering data from database. It is only checking starting and ending Character.In my database some keyskill are like that

Asp.net 3.5,4.0,C#,Sql server 2008,Silverlight 2.0,3.0.

My requirement is to check each word in "SkillReq" text.

View 3 Replies

DataSource Controls :: Filtering Between 2 Values In A Query From Dropdownlist Select?

Feb 17, 2010

I have dropdownlist of dates and depending on the date that the user selects from list, I would like to filter records that fall between the startyear and finishyear columns in the datasource. (My the problem is that I do not know how to declare the Startyear and Endyear from the query in the code as they appear underlined - probably the BETWEEN syntax is wrong too).

yYear = DropDownList1.Text
Using connection As New SqlConnection("Data Source=CHRIS-PCSQLEXPRESS;Initial Catalog=TorGHL;Integrated Security=True")
Dim cmd As String
cmd = "SELECT BarDetails.*, MenuHeadingId AS Expr1 FROM BarDetails WHERE (MenuHeadingId = 2)" & "WHERE " & yYear & " BETWEEN " & "(" &
StartYear & ")" & " AND " & "(" & EndYear & ")"
connection.Open()
Dim dapubcb As New SqlDataAdapterDim sqlcomm
As
New SqlCommand(cmd, connection)
dapubcb.SelectCommand = sqlcomm
Dim dspubcb As New DataSet("BarDetails")
dapubcb.Fill(dspubcb, "BarDetails")

View 4 Replies

DataSource Controls :: Select Query For Retrieving Data Between 2 Dates?

Jan 8, 2010

I want to create an application where I need to enter date to the ms access database.

I am a bit confused regarding how to make the user to enter date. The options avaliable are:

a. Shall I use a textBox?

b. Shall I go for 3 drop down lists?

or something else.

Some more questions:

1. what date format shall i use? (dd-mm-yyyy, dd-mmm-yyyy, etc, etc or anything else)

2. What datatype shall i use to store the date in the database?

3. What SQL query shall i use to retrieve the data between 2 dates?

let me know if there are multiple options available regarding this application.

I want to make this application as easy as possible for the user.

View 4 Replies

DataSource Controls :: Write Select Query To Get Counts In Row Values?

Jun 2, 2010

How to write select query to get counts in row values

View 6 Replies

DataSource Controls :: Select Query Not Working / Getting An Invalid Column Name Error?

Jul 9, 2010

i have the following select staement which deosnt work, can anyone advise me whats wrong with it:

string _name = ddl_Name.SelectedValue.ToString();
string cmd =
"SELECT ID, Telephone FROM User_List WHERE Name = '' + _name;

i keep getting an invalid column name error? and i know the syntax next to _name isnt correct. how are the single quotes meant to go?

View 3 Replies

DataSource Controls :: Using Values Selected From A "check Box List' In A SQL Select Query?

Jul 5, 2010

I have a table called 'Customer' that contains customer information. One of the fields is named "CustomerType". Each record in the 'Customer' table will contain the value of either "C", "I", or "O".

I have a form that contains a "check box list" named "Type". There are 3 values in the "check box list". The values are "C", "I", and "O". The user can select one or more of these values. I have a button on the form named "btnRunQuery.

When the user clicks on the button "btnRunQuery" I want to exectute a query that selects the records contained in the "Customer" table where the value in the field "CustomerType" equal the values the user selected in the "check box list". Example: If the user selected "C" and "O", then I want the select query to select all records that contain either "C" or "O" in the field "CustomerType".

I assume that what I need to do is to capture the values that the user selected in the "check box list" and put them in a variable. Then I need to format the "Where" statement in the query and add a "Parameters.AddWithValue" command.

View 2 Replies

DataSource Controls :: Linq Query To Select Parent Records Which Have Related Children

Jan 19, 2010

I have a basic CMS which I'm adding to a site to display some downloads organised into groups. I have two tables, one for the groups and one for the downloads. I'm using a repeated to display the groups with another repeater inside to display the children. This works perfectly.

However some of my download groups may not have any downloads related to them and I'd like to handle this by filter the groups so that only those with a relate download record(s) are shown.

I'm trying to do this with the query which populates the top repeater based on some ideas I read but I must be going wrong with the syntax.

Here is what I'm using to try and only select downloads groups which have downloads linked to them by the download group ID.

[Code]....

Can anyone offer any thoughts on how I should construct the query to perform this?

View 1 Replies

DataSource Controls :: Select Query Doesn't Work When Data Is Present In Arabic MS Sql 2005

Jan 26, 2010

This query does not return any record

[code]....

View 3 Replies

DataSource Controls :: Implementing A BLL / Contacts Table, The Select Method Is A Sql Query Against A Sql Server 2000 Database?

Feb 17, 2010

I'm implementing a BLL layer and have a few questions. First, in my DAL, there is a contacts table, the select method is a sql query against a sql server 2000 database. The preview data returns everyting as expected. The query is

[Code]....

The BLL method is built like so

[Code]....

When using the BLL method to a gridview, the results of the subquery are not displayed. There are also other methods, each having a different where clause for ContactRole_ID and each is having the same issue of not displaying the subquery reult in the gridview. No error, but no data is displayed for the subquery either. Here is the templatefield of the gridview

[Code]....

Another item that is causing an error is in trying to update a record. Here is the DAL update method

[Code]....

And the BLL update method

[Code]....

The error says i have extra parameters, but have no clue where the extra parameters are being picked up. The error isObjectDataSource 'odsContacts' could not find a non-generic method 'UpdateContact' that has parameters: _ContactID, _Active, _ContactName, _Office, _VirtualOffice, _Pager, _Fax, _Home, _Cellular, _Email, _ContactRole_ID, Active, ContactRole_ID, ContactName, Office, Email, VirtualOffice, Pager, FAX, Home, Cellular.And the objectdatasource

[Code]....

View 4 Replies

DataSource Controls :: Select All The Customers From "customers" Table From A Specific Country - Query Is Not Working

Feb 23, 2010

I want to select all the customers from "customers" table from a specific country. I write the following query but it is not working. why?

select *
From customers
where country = @country;[code]....

View 1 Replies

Forms Data Controls :: How To Display Records After Going Through The Query Builder And Select "Test Query"

Nov 5, 2010

I have a SQL Data Source that displays records after going through the Query Builder and select "Test Query" yet when I save it, go back to the design mode and select View in Browser I get nothing but a blank screen.

View 3 Replies

DataSource Controls :: Programmatically Setting ODS Select Method And Select Parameters?

Dec 22, 2010

The drop down list is used to determine what search criteria will be used to find an invoice. I tried to set the Select method in the switch statement. I don't understand how to set the Select Method and the select parameters programmatically though . I tried a few different ways but can't make the compiler happy. My ODS is in scope in the code behind. I'm not able to access it's properties though. The BAL resides in a separate project that is a ClassLibrary. I also have a using statement for the ClassLibrary project in the code behind.

give me an example of how to do this?

Mark up:

[Code]....

[Code]....

[Code]....

[Code]....

View 1 Replies

DataSource Controls :: Select / Returns Error No Overloading Method For Select?

May 9, 2010

protected void Button19_Click(object sender, EventArgs e)
{
SqlDataSource conn = new SqlDataSource();
conn.ConnectionString = ConfigurationManager.ConnectionStrings["Database2ConnectionString1"].ToString();
conn.SelectCommandType = SqlDataSourceCommandType.Text;
conn.SelectCommand = "SELECT FROM table1 (a, b)VALUES(@a,@b)";
conn.SelectParameters.Add("a",TextBox1.Text);
conn.SelectParameters.Add("b", TextBox2.Text);
int rowsAffected = 0;
try
{
rowsAffected = conn.Selectt();
}
catch (Exception)
{
Label1.Text = "Error";
}
finally {
conn = null;
}
if (rowsAffected != 0)
{
Label1.Text = "Data saved";
}
}

well it returns error no overloading method for select (P.S. same code work fine for insert)

View 5 Replies

DataSource Controls :: Declare Attribute With Select Top 1 / Error Incorrect Syntax Near The Keyword 'select'

Apr 14, 2010

I will declarate a attribute, but it gives me an error

This query works fine and returns 1 record from type int:

SELECT TOP 1 DataObjectVersionID
FROM tblDataObjectVersionPropertyValueText
WHERE PropValue like CAST('00010281' AS ntext)
ORDER BY DataObjectVersionID DESC

And when I will declarate a attribute/parameter it gives me an error:

DECLARE @dataObjectVersionId INT
SET @dataObjectVersionId = SELECT TOP 1 DataObjectVersionID
FROM tblDataObjectVersionPropertyValueText
WHERE PropValue like CAST('00010281' AS ntext)
ORDER BY DataObjectVersionID DESC

Error message:

Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'SELECT'.

View 4 Replies

DataSource Controls :: SqlDataSource And Parameters Query / Trying To Accomplish Is Building Dynamic Query

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

DataSource Controls :: Update Query Not Working When Using Query Builder To Configure Table Adapter

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

DataSource Controls :: Can't Find Query's / By Right Clicking On Database Created A Query In Server Explorer?

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

DataSource Controls :: How To Convert Sql Query Into Linq Query

Mar 10, 2010

select Groupid,GroupName,onorusername from palgroup where groupid in (select distinct Groupid

View 5 Replies

DataSource Controls :: Accessing FK From A Query Via Entity Query

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

ADO.NET :: Sql Query Select Inside A Select Statement?

Dec 2, 2010

i have two tables named

1.LookupPageInfo and (LookupPageInfoId,pathmessageID,pagemessageID)

2.Messages (MessageId,MessageText,ChannelID)

Now i need to write a query something like this........in the query i need to pass the pathmessageid and needs to get messagetext from Messages Table,i am not sure how i need to write the below query..can someone guide me how can i write a query......as below..

select LookupPageInfoId,
PathMessageID,
pagemessageID,
(select messagetext from Messages where MessageID=PathmessageId) as TEXT from LookupPageInfo

View 5 Replies







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