DataSource Controls :: How To Select / Use Two DBO For CommandText
May 2, 2010
I would like to combine two commandtexts into one
text1.CommandText = "SELECT Id, Heading as Head FROM dbo.Modul"
text2.CommandText = "SELECT Id, Caption as Head FROM dbo.Menu"
I want to combine these two into:
text3.CommandText = "SELECT Id, Heading as Head FROM dbo.Modul" + "SELECT Id, Caption as Head FROM dbo.Menu"
View 20 Replies
Similar Messages:
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
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
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
Feb 18, 2010
SQL Query with IF and Select
View 2 Replies
Jun 15, 2010
The following code is used to get a relation out of the database:
rel_SQL = "select * from Relatie where relatie_soort_nr = '" + rel_srt_nr + "' and relatie_naam like '%" + sel_Waarde.Trim() + "%'";
This code is a problem when you have a relation with ' in his/here name.
rel_SQL = "select * from Relatie where relatie_soort_nr = '1' and relatie_naam like '%L'%'";
As you can see there is one to many ' sign in the code, how can I solve this like problem?
View 3 Replies
May 14, 2010
I have a table with number fields, one of which is location. What I want is a select command which put all records for the selected location first then adds all the others on the end in what ever order they occur.
View 1 Replies
Mar 17, 2010
If I run the following SQL script:
[Code]....
View 3 Replies
Apr 7, 2010
i have two tables (Users, Roles) and each user belongs to one role. Can I make a sql query that returns 10 newest users from each role in one query?
View 5 Replies
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
Apr 24, 2010
I want the select statement for the above scenario.
View 2 Replies
Apr 30, 2010
How would you handle an INSERT that gets some values from another table using SELECT, where you wanted some values to come from the source table record and other values to come from a different parameter source like a session value? Is this possible?
View 3 Replies
Apr 17, 2010
I need to execute the stored proc accross the parameters resulted from select statement
I have created one stored procedure which require one parameters ( username ) ..
i need to execute this SP accross the Select Statement which lists all the username
somethibng like :
Set @username = (Select usename from my table)
EXEC dbo.Duplicate_Data @username
View 7 Replies
Mar 17, 2010
I have a SQL select statement with inner joins to get a total number of records for the statement. I have tried using count with group by's but it just counts one for each record instead of giving me the total number of records for the query. Here is the query:
[Code]....
View 3 Replies
May 11, 2010
If I have a linq statement like:
[Code]....
There may be a lot of data in the Blogs table. What if all I wanted was say BlogID, BlogTitle and BlogAuthor and nothing else, is there a way to do this in an effort to make the sql more efficent?
Along the same lines in my DataContext (.dbml) file I added some associations between some of my tables. This makes coding nice when I do a linq statement that will join those tables automatically for me but my concern is does it do that everytime, thus making all my linq quieries inefficient?
View 1 Replies
Jan 14, 2011
I have a query that looks like this attached to a sqldatasource :
SELECT [fldBaseline] FROM [BI_PATHS_Target_Baseline] WHERE fldBranch = @fldBranch and
fldyear=@fldyear and fldcategory = @cat
and i want to make a LABEL to read that fldbaseline value and i tried this :
[Code]....
btw the @fldbranch is pulling from a dropdownlist and so it the @year but the @cat is just defined always as 'LEAN' But im not sure what to put inside the select() part. i know you have to put atasourceselectarguments.empty if no parameters, but what would I do here since their are 3?
View 6 Replies
Apr 22, 2010
My query was SELECT ID FROM TBLCARS WHERE (ID IN (1, 5, 3, 6))
this will usualy produces the result 1,3,5,6 order.But i want the result in the specefied order of ids.ie:1,5,3,6;ie;first get the row with id 1,then with id 5,then id 3,and last 6.
View 11 Replies
Mar 17, 2010
[Code]....
Select statement across three tables
View 15 Replies
Jul 6, 2010
I need to create a SELECT statement for a table that excluded the TOP 10 records.
"SELECT TOP 10 field1,field2,field3 FROM AppData ORDER BY field1 DESC" returns the first 10 records from the table but I need to retrieve only from the 21st record onwards.
I simply don't know how to do it because I'm not that strong with SQL. I searched the forum for some answers but can't find a solution that I can understand.
View 4 Replies
Jan 1, 2010
I have a problem with my SQL statement that only needs to show future dates in the Gridview.I use vb, vs 2005.I want a DateTime Field(TEndDate) to act as a control field in that only future dates (WHERE TEndDate >= Now.Date.Date) should be returned.It asks for my paramaterized value when I'm building the query.I'm unsure about the source I should select for the query.(The options are: None/Control/Cookie/Form/Profile/Querystring/Session)I'm losing my mind with this!Here is my code:
[Code]....
View 2 Replies
Jul 6, 2010
I am reading an integer named "CostIndex" from a database table.I need to cast it to an integer and then pad the result withleading zeroes.So if CostIndex is only one digit then I need to pad it with 3 leading
blanks: 0007I know how to find the length, using LEN,but I don't know what to do beyond that? select CAST(CostIndex AS VARCHAR(4)) from TableRoot
View 3 Replies
Mar 16, 2010
I need to select the rows between 20 to 30 from a table without using where condition. How is it possible?
View 2 Replies
Jan 14, 2010
Where can I find documentation on the syntax that is expected for LinqDataSource.Select? It seems to be different from what I would do with Linq inline in C# code. For example, concatenateing something in Linq I would normally just do this in the projection:
new { FullName = (person.FirstName + " " + person.LastName ) }
However, with a LinqDataSource the only way I've found to do this is like this:
new ( String.Concat(person.FirstName, " ", person.LastName) as FullName)
I literally spent hours trying to figure this out, and only succeeded when I found a blog where someone gave this verbatim as an example. So I still don't understand why the syntax is different, the braces versus parens, aliasing, Concat operators. Next time I do this I want a better understanding so I am not playing this guessing game. It's like being handed a compiler, and trying to write a program when you don't know what language the compiler compiles.1. Are there different "flavors" of Linq? Like a VB Linq, and C# Linq?2. If so, is the LinqDataSource using a VB flavor of Linq?3. Really, what is really important to me, where can I find documentation on this particular falvor of Linq that the LinqDataSource expects? The documentation for the LinqDataSource itself gives nothing more than extremely simplistic examples.
View 1 Replies
Jun 8, 2010
I have a simple page that will display data from a particular category, using a querystring to filter my data in my sql select statement.
However, I would like to show all my data if there is no querystring present. Is there a simple way to do this?
View 6 Replies
Jan 14, 2010
How can I select a random row and then update or delete it? I've found how to get a random row, using SELECT TOP 1 column FROM table ORDER BY NEWID() do I have to make another select using this result in order to update the row, or it can be done more efficiently?
View 10 Replies