Web Forms :: Query.CopyToDataTable(); Does Not Work When Select New Is Used
May 12, 2010[Code]....
Why does'nt query.CopyToDataTable(); not work for me on Vs 2008. Since I use the "select new" in my linq query above.
[Code]....
Why does'nt query.CopyToDataTable(); not work for me on Vs 2008. Since I use the "select new" in my linq query above.
This query does not return any record
[code]....
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 Repliesi 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
What is difference between select { } and select new {} In Linq Query
View 3 RepliesI am writing a linq query to select a blogpost,
[code]....
The blogpost i am testing got 3 tags attached to it. The table structure is:
(table)BlogPost -> (table)BlogPostTags <- (table)Tags
So the BlogPostTags table only contains 2 fields, BlogPostID and TagID.
When i run the query above i get 3 results back. Same blogpost 3 times but with 1 tag in each. It should return 1 post with 3 tags. The problem lies in the Tags query above.
How can I SELECT second if first SELECT returns nothing?
View 8 RepliesI have a gridview that has a sqldatasource for it's data and it works well. I also have four dropdown lists that I need to have filter the data in the grid if they have a value selected. Here's my query:
[Code]....
What I need is if a user selects an Asset_Tag from a dropdown list the gridview should requery with the Asset_Tag as a parameter so only that record gets called up. Is there a way to do this in the selected indexchanged event? The same would hold true for the other DDLs. It seems like if I assigne the datasourse programmatically I lose the builtin sorting ability which isn't acceptible for this application.
I have a TableAdapter that consists of an SQL SELECT query.
Need to create an "if" statement that checks to see if the query returned any records.
Tried "HasRows" but Visual Studio 2010 says: Error 2 'Maine_Innkeeper_Site_2010.App_Code.DataAccessLayer.MaineInnsDataset.membersDataTable' does not contain a definition for 'HasRows' and no extension method 'HasRows' accepting a first argument of type 'Maine_Innkeeper_Site_2010.App_Code.DataAccessLayer.MaineInnsDataset.membersDataTable'
could be found (are you missing a using directive or an assembly reference?) E:Ed dataclientsMaine InnkeepersMIA website 2010Maine Innkeeper Site 2010lodging-search-output.aspx.cs 49 83 Maine Innkeeper Site 2010
What's the proper way to check if HasRows is wrong?
[Code]....
I have a probelm with my SQL select statment..text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator.In my case its image.. When my select statment does not include images columns its working fineWhen I select 2 images then SQL query erro show up..
View 3 Repliesi create view in sql server and execute a select query using AND operator on it using vb.net and bind data with gridview...but i am not getting result in grid
View 3 Repliesthis is my table
dept Table
dept Id (primary key column)
dept Name
101
sales
102
admin
[Code]....
using System;
using System.Collections.Generic;
using System.Linq;
using System.Data.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace find.Admin
{
public partial
class WebForm1 : System.Web.UI.Page
{
private
class servicetimeofday
{
public int servicetimeofdayid {
get; set; }
public int serviceid {
get; set; }
public int timeofdayid {
get; set; }
}
protected void Page_Load(object sender,
EventArgs e
{
List<servicetimeofday> servicetimesofday =
new
List<servicetimeofday>
{
new servicetimeofday() { servicetimeofdayid = 1, serviceid = 1, timeofdayid = 1 },
new servicetimeofday() { servicetimeofdayid = 2, serviceid = 1, timeofdayid = 2 },
new servicetimeofday() { servicetimeofdayid = 3, serviceid = 2, timeofdayid = 1 },
new servicetimeofday() { servicetimeofdayid = 4, serviceid = 2, timeofdayid = 3 }
};
GridView2.DataSource = servicetimesofday;
GridView2.DataBind();
var itemstocheck = from
servicetimeofday in servicetimesofday
where servicetimeofday.serviceid == 2
select ne
servicetimeofday.timeofdayid
};
GridView3.DataSource = itemstocheck;
GridView3.DataBind();
foreach (var timeofdayid
in itemstocheck)
{
foreach (ListItem i
in CheckBoxList2.Items)
{
if (i.Value == timeofdayid.ToString())
{ i.Selected =
true; }
}
}
}
}
}
i want know, How we can select and pass a grid column value to a text box for other work
View 3 Repliesi wants to display the related informations of each record of dataset. That mean, dataset having rows for A,B,C and etc..
Then i wants to display the information in same Gridview of each record(A,B,C). i wrote the below my coding, it dispaly info of the last row of dataset only. pls correct the coding.
[Code]....
How do I do this? I want to search my database in listview form with the text from a textbox or an item from a drop down list which is on another page.
View 1 RepliesI have a GridView; one of the columns displays concatenated records from a tables. to extract the records that are going to be concatenated and put in this column, i have used: FOR XML path('') and it works just fine for displaying those records. the problem now is the whole gridview can not be sorted anymore and gives me a 404, document not found, error whenever i try to click the columns to sort. here is my select statement for my sql datasource select command:
SqlDataSource2.SelectCommand = "Select a1.*, keyword = substring( ( SELECT DISTINCT ', ' + keywordName FROM keywords JOIN key_mm_articles ON key_mm_articles.keywordID = keywords.keywordID WHERE key_mm_articles.articleID = a1.articleID FOR XML path(''), elements ),2,500) FROM articles a1 WHERE title LIKE '" & titles & "' Order By a1.articleID"
I'm trying to write a SQL Query that will grab items from a database that match the username of the currently logged in user. They are logging in using Active Directory credentials through a forms-based login page. I decided to create an ASP Label that will hold the username of the person who has logged in and the login status control, code:
[Code]....
I added a statement to the Page_Load event that should automatically populate the field with that user's name, code:
[Code]....
However, I get the error "System.Data.SqlClient.SqlException: The multi-part identifier "lblUn.Text" could not be bound." when I attempt to load the page after logging in. How can I fix this? Also, I might need to place this in a separate thread, but can someone check my SQL Syntax on the query? I'm not fully convinced it will work properly when I go to load the page. Code:
[Code]....
how to get the value from SELECT query from a table
protected void Button_Click(object sender, EventArgs e)
{
string select_qry = "SELECT ID, USER, FILE, DATE, LASTUSED from FILE_INFO where USER = '" + user + "'"; // ID is primary key
SqlCommand cmd = new SqlCommand(select_qry);
GridView1.DataSource = GetData(cmd);
GridView1.DataBind();
}
private DataTable GetData(SqlCommand cmd)
{
DataTable dt = new DataTable();
SqlDataAdapter sda = new SqlDataAdapter();
cmd.CommandType = CommandType.Text;
cmd.Connection = conn1;
conn1.Open();
sda.SelectCommand = cmd;
sda.Fill(dt);
return dt;
}
I have different USERS I want to get ID of user if user is different say 'Sheena' has ID value from 1-10 but if user is 'Sara' and she is having ID from 11-20 so I want to get specially ID of particular user how do I get ID from select query can any one know)
Need to do a summary report of two items, sales and commissions by sales person, by date range. There are only a handful of salespeople. I messed around with SELECT SUM() for a few hours last night. It works easily, up until you need to do a few table joins, to say join on employee id to pull in names. Then it starts getting pretty convoluted, fairly quickly. Question is, is there maybe an easier way of doing this in asp.net than through the sql? It is Access, so I don't think LINQ will work, right? Just wondering if there isn't a quick, easy way of doing this that I don't know about.
View 2 RepliesSQL Query with IF and Select
View 2 Repliesi have been having trouble trying to find out what is wrong with my sql select query... i wanted to select a sessionID by comparing the tourID and dates. the dates datatype at the database is datetime and the value of itemSessionDate is in string. i tried to convert itemSessionDate to date and dateAndTime but it gave me mm/dd/yyyy while the date in my database is dd/mm/yyyy hh:mm:ss. so i thought i can try using the itemSessionDate string as it has the same value as the one return from the database. but it keeps on goin to the if not reader.hasRows and quit the statement
[Code]....
I have been utilising a SELECT query such as the following:
SELECT SRFILE.SR_GROUP, SRFILE.SROWNERSHIP, SRFILE.SRCONMAE, BSFLBWF_1.Incidentx,
BSFLBWF_1.Severityx, BSFLBWF_1.Openx, BSFLBWF_1.Closex, BSFLBWF_1.Closurex, BSFLBWF_1.Customerx, BSFLBWF_1.Availabilityx, BSFLBWF_1.KPIx,
CONVERT(Decimal, BSFLBWF_1.Minsx) AS Expr1, BSFLBWF_1.Unusedx, BSFLBWF_1.FirstIntx, BSFLBWF_1.RepeatIntx, BSFLBWF_1.Corex,
BSFLBWF_1.OffPeakx, BSFLBWF_1.NonCorex, BSFLBWF_1.DedTypex, CONVERT(money, BSFLBWF_1.SchoolChargex) AS Expr2, CONVERT(money,
BSFLBWF_1.LANMLEChargex) AS Expr3, BSFLBWF_1.KPIFailx, BSFLBWF_1.Overridex, BSFLBWF_1.Reasonx, BSFLBWF_1.Contactx,
SRFILE.SR_CLOCK, SRFILE.SR_BACK_REASON, CONVERT(int, BSFLBWF_1.Minsx) / CONVERT(decimal, BSFLBWF_1.FirstIntx)
* 100 AS PERCENTAGE
FROM support.SRFILE INNER JOIN
BSFLBWF AS BSFLBWF_1 ON BSFLBWF_1.Incidentx = SRFILE.SRONUMBER
WHERE (BSFLBWF_1.Closex IS NULL) AND (BSFLBWF_1.DedTypex = 'School' OR
BSFLBWF_1.DedTypex = 'LAN-MLE')
UNION ALL
The rest of the query continues as the above albeit selecting the same data from different tables and works fine.
The issue I have is that I want to Select some more data (another SELECT query) but with a different Where clause e.g. WHERE (BSFLBWF_1.KPIx NOT LIKE 'KPI%' OR
BSFLBWF_1.KPIx NOT LIKE 'Proactive%') AND (BSFLBWF_1.Availabilityx LIKE '')
The problem is that this WHERE clause returns data which the above in bold has null values for (and thus doesnt work). Im still selecting the same data its just the WHERE Clause has changed. Is it possible to run such a query? If so, can it be done via a sub query?
f i have one item in my dripDown list and i want to select it like to delete from the db. but the function didnt work because,it didnt change is "selected item", or if my drop downlist starts with somethins that i want to delete but i need to change the index first but i dont want to delete other items.
View 8 RepliesI am trying to do a SELECT ... WHERE ... IN construct, using a parametrized query with Oracle (odp.net) and I cannot make it work correctly.
[Code]....
The STATUS column is NUMBER(2) in the database. My problem seems to be related to getting the correct OracleDbType. I've tried Varchar2, Long, Decimal... nothing works. Should I go for the ArrayBindSize construct?