|
If you are using SQL Server 2005, there is a simple way:
<br />
SELECT TOP(@N) web_News.ArticleDate, web_NewsLocalized.ArticleTitle,<br />
web_NewsLocalized.ArticleText<br />
FROM web_News INNER JOIN web_NewsLocalized ON<br />
web_News.ArticleId=web_NewsLocalized.ArticleId<br />
WHERE ((web_NewsLocalized.ArticleCulture)=[@Culture]) ORDER BY web_News.ArticleDate DESC;<br />
|
|
|
|
|
Hi,
I am using Access. The top (@N) is not working. I get an error when trying to save the Query.
I have been looking in internet but I can't find the solution.
I also tried [@N] but no luck.
Any idea?
Thanks,
Miguel
|
|
|
|
|
<br />
SELECT web_News.ArticleDate, web_NewsLocalized.ArticleTitle,<br />
web_NewsLocalized.ArticleText, (SELECT COUNT(*) FROM web_News AS B WHERE B.ArticleDate>=A.ArticleDate) AS RowNumber<br />
FROM web_News AS A INNER JOIN web_NewsLocalized ON<br />
web_News.ArticleId=web_NewsLocalized.ArticleId<br />
WHERE ((web_NewsLocalized.ArticleCulture)=[@Culture] AND RowNumber<=@N) ORDER BY web_News.ArticleDate DESC;<br />
I am not sure wheather it works, I've not tested yet, but just try it anyway. The performance will be a big problem
|
|
|
|
|
I am attempting to use a reportviewer control in a web app to access a working RS report stored on a Report Server. The report displays correctly when I access it from the application using a URL with a Response.redirect.
I have read the article "Integrating Reporting Services 2005 Into a Web Application" on this site, and have stepped through the instructions for setting the properties, etc. When I try to execute the report, I can see the "Report Being Generated" very briefly (sometimes), then I get the message "Execution '2fxr4rrhj1nah355k5vnbs45' cannot be found".
Any clues?
catmom
|
|
|
|
|
I have the following table field name = "ordDate" which holds DateTime for orders. Ive tried the query below but without success. I need to get all information based on the passed "DateTime". any help will be apreciated
select *
from order
WHERE ord_date = CONVERT .ToDateTime('14/09/1994')
|
|
|
|
|
<br />
select *<br />
from order<br />
WHERE ord_date = @ComparedDate<br />
@ComparedDate is a DateTime parameter, you have to provide it's value from caller.
<br />
Dim cmd as new SqlCommand(select * from order WHERE ord_date = @ComparedDate", conn)<br />
cmd.Parameters.Add(new SqlParameter("@ComparedDate", SqlDataType.DateTime)).Value=Convert.ToDateTime("14/09/1994")<br />
Dim reader as SqlDataReader=cmd.ExecuteReader()<br />
...<br />
|
|
|
|
|
How do I Commit changes that I edit in a DataGridView that I have used databinding from my SQL Server?
_____________________________
...and justice for all
APe
|
|
|
|
|
Hi,
Is there a way to restore a database with using .bak file? Either from "data file" or "log file"? I got a copy of those from the Microsoft website but how to restore this?
Many thanks.
|
|
|
|
|
Create a new database of the same name.
Then restore the bak file over the newly created database. The thing you need to watch for is that the bak file stores the file location of the log and data when it was backed up. You will need to change this to the actual file locations on your computer.
|
|
|
|
|
Hi,
I executed a stored procedure through VS2005 and the true boolean coloumsn came backs -1, and false as 0. Why didn't it display 1 for the true coloumns?
Regards,
ma se
|
|
|
|
|
In this case, the database stored boolean as a signed type (integer for example). All bits will be 1 for true and 0 for false. If first bit is 1, then that value is a negative one.
|
|
|
|
|
It has been a very frustrating effort attempting to find the root cause of this problem. I have searched the web sites and there is no definitive explanation. Likewise, this same message has been posted on Microsoft's SQL Server forum. There have been many viewers, but no responders.
We are running a Visual Studio C++ application using Sql Server / ODBC. SQL Queries are formatted and exceuted from the C++ code.
This particular SQL Error occurs about once every few months. Since the time of the last error, I added additional debug statements which log the exact format of the SQL Query that is being executed.
This is the SQL query that just failed.
SELECT * FROM [LaneInventory] WHERE (LaneInventory.LocationName = 'LANE_06');
The query that failed is executed hundreds of times within a 24 hour period every day, with the only exception being the location name changes in the query. The same exact query identified above was executed successfully about 15 minutes prior to this failure.
The SQL Exception message is very misleading.
I am wondering if SQL Server gets into a confused state every one in a while, or maybe it is a problem with the ODBC driver. The C++ application code is running on Windows 2003.
AbbyDabby
|
|
|
|
|
I'm not expert on databases, but the error is "Attempt to open a table failed"...so is it possible that your problem is caused by two people accessing the same file at the same time...one of them failing to open it because the other one had it locked? Or is there some other scenario where that file could be locked or unavailable for any reason?
|
|
|
|
|
Hi,
I currently have a DataGrid which retrieves the Surname of a user into one of the columns using an SQL View.
I would like to have the SQL View retrieve both Surname AND Forename.
Here's the current view:
SELECT tblProject.inProjectID, tblProject.vchProjectName, tblUser.vchSurname, tblProject.dtStartDate, tblProject.dtCompletionDate
FROM tblProject INNER JOIN
tblUser ON tblProject.inProjectManagerID = tblUser.inUserID
The view allows the display of the Surname. I would like to display "Surname, Forename" i.e. "Smith, John"
I used the following query for application on a DropDownList:
"SELECT tblUser.inUserID, tblUser.vchSurname + ', ' + tblUser.vchForename AS ForenameANDSurname FROM tblUser ORDER BY tblUser.vchSurname"
I just can't seem to fit it into the View
Any Ideas?
Thanks
|
|
|
|
|
Dayekh wrote: I used the following query for application on a DropDownList:
How do u fil DropDownList???
Do u set DataSource,DataValueField,DataTextField???
|
|
|
|
|
Yes indeed, I set all three of them.
Remember, the data text field will be the new alias that you specified for the fields.. ie forename field + surname field = "Fullname"
|
|
|
|
|
ur alias column (alias columns is forename field + ', ' + surname field as fullname) have to be DataTextField of dropdownlist
i.e
forename field + ', ' + surname field as fullname<br />
<br />
DropDownList1.DataTextField = "fullname";
|
|
|
|
|
Sorry I dont think I made myself clear..
I have already succeeded in populating my dropdown list. It shows:
"Surname, Forename"
I am referring to doing the same for a datagrid column. The column is already populated using an SQL View as shown in original post. Instead of having the column display:
"Surname"
I want it to display:
"Forename, Surname"
see what I mean ?
|
|
|
|
|
in ur view instead of surname set forename and instead of forename set surname
i.e
select ........ forename + ', ' + surname as fullname<br />
<br />
DropDownList1.DataTextField = "fullname";
|
|
|
|
|
Thank you very much for your replies..
Works now!
Turns out I had to remove the following bold entry:
SELECT ..., tblUser.Surname, ... FROM ...
and place:
tblUser.Forename + ' ' + tblUser.Surname AS Fullname instead!
Lol, Thanks.. it helped a lot. At least just to show me how trivial this was!
|
|
|
|
|
Never mind dude u are welcome...
|
|
|
|
|
Hello,
I have two tables with the following fields:
1. Table "web_Content"
Fields: [ContentId] > Primary Key;
[ContentName];
[ContentPage].
2. Table "web_ContentLocalized"
Fields: [Content_LocalizedId] > Primary Key
[ContentId] > Joined to ContentId in table "web_Content"
[ContentCulture]
[ContentHtml]
I want to INSERT a new record in both databases.
What I mean is that a new record will add values to [ContentName];
[ContentPage]; [ContentCulture] and [ContentHtml].
[ContentId] and [Content_LocalizedId] are autonumbers.
[ContentId] in table "web_ContentLocalized" should be the same as in
[ContentId] of "web_Content" table.
Anyway, I tried but until now I was able to make this work.
This is what I have:
INSERT INTO web_Content ( ContentPage, ContentName )
SELECT web_Content.ContentPage, web_Content.ContentName
FROM web_Content INNER JOIN web_ContentLocalized ON
web_Content.ContentId = web_ContentLocalized.ContentId;
Thanks,
Miguel
|
|
|
|
|
An INSERT statement can only target one table.
It is possible to target an INSERT statement to a view in SQL Server if you're prepared to create an INSTEAD OF trigger on the view, but this trigger will have to be coded to perform an INSERT into each table separately.
The general way of handling this is to use the SCOPE_IDENTITY() function to discover the identity value of the last row inserted.
You could consider creating a stored procedure:
CREATE PROC uspInsertWebContentLocalized
(
@contentName varchar(n),
@contentPage varchar(n),
@contentCulture varchar(n),
@contentHtml varchar(n)
)
AS
INSERT INTO web_Content ( ContentName, ContentPage )
VALUES ( @contentName, @contentPage )
INSERT INTO web_ContentLocalized
( ContentId, ContentCulture, ContentHtml )
VALUES
( SCOPE_IDENTITY(), @contentCulture, @contentHtml )
|
|
|
|
|
Hi,
I want to search a DataSet (dataset contains several tables) for a specific value. (Writing a login method that shall verify if the user exists and has the correct password)
I am bit confused about; DataSet, BindingSource, DataTable etc.
thanx in advance
Regards
/Christoffer
|
|
|
|
|
What specifically are you asking?
You seem to know what a DataSet is...It is a collection of DataTables.
Or are you asking about connecting to a Data Source like an access database or something? In that case you would need to research command objects, connection objects, and data adapters. I'm sure you can find a bunch of articles about connecting to a datasource here at codeproject.
|
|
|
|