.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Exclude the last row returned

Posted By:      Posted Date: September 02, 2010    Points: 0   Category :Sql Server
I have 2 issues actually, I have a sql query Where i have to change from GMT time to EST which is easy enough.  My problem comes in where I'm just wanting to get the values for today, the sql query is displaying data that has been converted and is no longer in todays date. Here is my Sql Statement: SELECT V301446F as [Camp#3 MW], (Select Dateadd(hour,-5,TIME)) as 'Time' FROM dbo.HISTSAMPLES3 WHERE (TIME >= DATEADD(Day, DATEDIFF(Day, 0, GETDATE()), 0))   Which gives me these results: 823.79677327474 2010-09-01 19:00:00.000 823.898544311523 2010-09-01 20:00:00.000 823.796752929688 2010-09-01 21:00:00.000 824.71278889974 2010-09-01 22:00:00.000 825.425257364909 2010-09-01 23:00:00.000 808.427988688151 2010-09-02 00:00:00.000 793.160990397135 2010-09-02 01:00:00.000 704.103500366211 2010-09-02 02:00:00.000 774.433471679688 2010-09-02 03:00:00.000 809.445785522461 2010-09-02 04:00:00.000 804.967468261719 2010-09-02 05:00:00.000 820.845153808594 2010-09-02 06:00:00.000 823.898549397787 2010-09-02 07:00:00.000 824.916356404622 2010-09-02 08:00:00.000 823.796778361003 2010-09-02 09:00:00.000 826.035934448242 2010-09-02 10:00:00.000 825.119913736979 2010-09-02 11:00:00.000 825.527028401693 2010-09-02 12:00:00.000 822.67719523112 2010-09-02 13:00:00.000 1636.60131835938 2010-09-02 14:00:00.000 The second issue and the one i'm most conce

View Complete Post

More Related Resource Links

Where to Filter the companies returned by the EF?



I am just starting with dynamic data. I have an enttity framework called UsersModel.edmx.

It returns a list of all companies in the tblCompany table. This list is really big.

I need to filter the list returned to all user controls on the client so that it only returns the company that have a CompanyTypeId= 2 or CompanyTypeId= 3 and company name != "".

1 - Is it possible to filter the company list returned on the server so that I can filter only once for all the controls that use that on the client?

My ideas was to do something like this using linq and lambda but I am not sure how:

return tblCompanys.Where(c => c.CompanyTypeId == 2 || c.CompanyTypeId == 3 && ).Where(c=>c.CompanyName != "").OrderBy(c => c.CompanyName).Distinct().OrderBy(c=>c.CompanyName);

2 - I have created a partial class and a metadata class and added the DisplayColumn attribute to use the company name and sort by company name ascending.

Could I use the code to filter the returned companies in this? where?

namespace MarsMedicalModel
    [DisplayColumn("CompanyName", "CompanyName")]
    public partial class t

Exclude Folder from Website in Visual Studio


For projects such as forms apps and class libraries you can exclude folders which reside in the directory from the project. That menu option does not seem to exist when you create a website in VS 2005, is there any way to do it?



how to evaluate nothing value returned by sql datareader in vb.net


When a sql query returns NULL , I can use the following code to evaluate:

While (dr.Read())
                If IsDBNull(dr(0)) Then
                End If
            End While


When a sql query returns nothing, neither IsDBNull nor is Nothing works.  I don't know why some sql queries return null while some return nothing when there are no data returned.  But anyway, can somebody tell me how to evaluate nothing value returned in sql datareader in vb.net?  When I put the cursor over signInfo variable in debug mode, I can see Nothing show as its value.  But the line does not work

if signInfo is Nothing then 


Thank you!

Exclude the author name from the search results



How can i prevent author's name to appear in search results. shows many results when i search the "author.name".

I want, MOSS 2007 Search get results from the content only the user sees.


Using the BDC API how to catch the returned code when executing a stored procedure?

using BDC API, how can i catch the return code a stored procedure returns?

I tried Entity.Execute to execute a generic method. However, it returns an empty Entity table.

I know you can do it by setting up an output variable. I prefer returning an integer for tracking errors.

Any ideas?



The remote server returned an error: (405) Method Not Allowed.



{System.Net.WebException: The remote server returned an error: (405) Method Not Allowed.
   at System.Net.WebClient.UploadFile(Uri address, String method, String fileName)
   at System.Net.WebClient.UploadFile(Uri address, String fileName)
   at System.Net.WebClient.UploadFile(String address, String fileName)
   at Test.Page_Load(Object sender, EventArgs e) in c:\Inetpub\wwwroot\WebSite1\Test.aspx.cs:line 35}

Windows application, automated process will run on local user system...
trying to upload a file to website folder. website address:

System.Net.WebClient wc = new WebClient();
wc.UploadFile(website address, "c:/1.pdf");

Getting error from above line.. Am doing something wrong??
I dont want to use ftp or share folder logic..
is there any other way to upload the files to server??

Exclude a word regex

Currently i am using one regex for accepting some records from a file.  That regex is ^[a-zA-Z0-9| ].*$. This regex accepts record starting with alphanumerics or blank space.I want to modify this regex such that, previous conditions should be there and regex should not accept record starting with word 'bbb'. Which regex should be used?

Problem passing custom object returned by the same webservice among two separate projects

I am running into casting issue with this scenario: 1. I made a custom object lets call it EmployeeObject.  2. The Employee object is wrapped in the EmployeeWebservice.  3. I have a client application project lets call it EmployeeClientApplication and a class library called DoSomeWorkClassLibrary.  Both EmployeeClientApplication and DoSomeWorkClassLibrary reference the EmployeeWebService and need to be able to pass the EmployeeObject back and forth.  4. The EmployeeClientApplication also references the DoSomeWorkClassLibrary. 5. The employeeObject in the EmployeeClientApplication becomes EmployeeClientApplication.EmployeeWebService.EmployeeObject. 6. The employeeObject in the DoSomeWorkClassLibrary becomes DoSomeWorkClassLibrary.EmployeeWebService.EmployeeObject. 7. The DoSomeWorkClassLibrary has a method called DoSomeWork that takes an EmployeeObject. When I try to pass employeeObject from EmployeeClientApplication to DoSomeWorkClassLibrary by doing something like this: DoSomeWorkClassLibrary.DoSomeWork(EmployeeClientApplication.EmployeeWebService.EmployeeObject), I am getting Unable to convert EmployeeClientApplication.EmployeeWebService.EmployeeObject to DoSomeWorkClassLibrary.EmployeeWebService.EmployeeObject.  I have searched high and low to fix this issue, I have tried changing the namespace of the reference.cs file of the webservice in

Deserialization issue with returned from web service

Hi, I have a VS 2008 C#  client using a proxy generated by the Service Reference tool from a schema for a (prob Java?) ASMX web service.  I got serialisation errors when I tried connecting to the service around<xs:date> date fields, and on inspecting the incoming XML discovered the date format was yyyy-mm-dd hh:mm:ss.sss.   So 2 questions really.. 1) Is the schema I've been supplied with incorrect? 2)Is there a way to work around this, apart from manually editing the schema to xs:datetime and regenerating the classes?   Thanks MJ

Integer Value of 80 being returned as 20480

I'm writing an applicaiton that lists all of the ports of existing processes on the system.  However the system is returning the value of 20480 as the value for port 80.  I've found a couple of articles that would indicate that the discrepancy is because of the "endianess" of the underlying system and that reversing the byte order would resolve the problem.  However when I convert the return value to an array of bytes the values show up as 0,80,0,0.  Even reversing the order of the bytes wouldn't return the appropriate value of 80. Specifically I'm calling into the iphlpapi.dll using the following function [DllImport("iphlpapi.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]         private static extern int GetExtendedTcpTable(IntPtr pTcpTable, ref int dwOutBufLen, bool bOrder, int dwFamily, TCP_TABLE_CLASS dwClass, int dwReserved); Here's some additional code from the listing this.m_TcpTable.Add(new TcpEntry(entry.dwState, entry.dwRemoteAddr, entry.dwRemotePort, entry.dwLocalAddr, entry.dwLocalPort, entry.dwProcessId)); public TcpEntry(TcpState state, UInt32 remoteAddr, int remotePort, UInt32 localAddress, int localPort, int processID)         {             this.m_State = state; &nb

Subquery returned more than 1 value.

Hello, I need a gander at this query to figure out what i'm doing wrong. update Performance set pmpg = (select PMPG from Performance_Calculator where EFFDT_Converted = (select CAST(FLOOR(CAST(getdate() AS FLOAT)) AS DATETIME)) and Performance.DR_CODE = Performance_Calculator.FW_OWN group by Performance_Calculator.FW_OWN, Performance_Calculator.PMPG); basically the performance calculator, in the subquery, does return around 320 rows of data.  I thought the where clause would match up the rows of data and insert the pmpg into the performance table but instead I get subquery returned more than  1 value.  This is true but only if the performance_calculator.fw_own = performance.dr_code wasn't there.  I'm confused on this... any suggestions?

[SSRS 2008 R2]Report Builder Access error-The remote server returned an error: (401) Unauthorized.

Hello,        I am able to login Web Service URL and report manager using computer name and report builder is also working fine.  http://RPTSRV/reportserver   (RPTSRV is report server name. web service url working fine. all accessible) http://RPTSRV/reports  (report manager working fine and all accessible ,report builder too) It means I am able to access everything locally right? http://rs.test.abc.com/reportserver  (web service url working fine. all accessible)  http://rs.test.abc.com/reports    (Report manager working fine and all accessible accept report builder)(I carefully checked the link and its taking rs.test.abc.com/reportserver.....)     when I click on reportbuilder button in report manager it shows me error dialog box with following error log!! I tried from local and remote computer too but gives the same error both side. I am not sure but I am just thinking is this double hop kerberos security issue? Please help me to solve this problem. I am finding solution from last 4 days. Reporting Service configuratin tool settings Web Serivice URL -  all set to default Report Manager URL - all set to default Environment - Distributed deployment Server1(report_srv) --Windows server 2003, Installed sql server 2008R2 reporting service,

Error in RESTORE in LOG FILE. Anyway to exclude it?

I'm trying to install a database (on a SQL Server 2008 machine) with test data sent by a partner company in the form of a .BAK file. (Version of SQL Server they are using unknown). I'm using this script: Use Master RESTORE DATABASE XEMS FROM DISK = 'C:\temp\xemstest6-29.bak' WITH REPLACE, MOVE 'XEMS' TO 'E:\XEMS DATABASE\XEMS.MDF', MOVE 'XEMS_Log' TO 'E:\XEMS DATABASE\XEMS_Log.LDF' The Restore process churns for a while, then I get: Processed 2576 pages for database 'XEMS', file 'XEMS' on file 1. Processed 5 pages for database 'XEMS', file 'XEMS_log' on file 1. Msg 3283, Level 16, State 1, Line 2 The file "XEMS_log" failed to initialize correctly. Examine the error logs for more details. Msg 3013, Level 16, State 1, Line 2 RESTORE DATABASE is terminating abnormally. At this point the database is unusable - trying to do anything with it produces an error indicating the database is still in a Restore state. There is some problem with the LOG portion of the backup, which I really don't need anyway. I'd like to just NOT restore the log. Came across this article which seemed to refer to the exact problem I'm having...  http://support.microsoft.com/kb/915385/en-us They offered this suggestion: "Use the WITH NO_LOG clause during the restore process." However - in checking the RESTORE syntax.... http://msdn.microsoft.com/en-us/libr

error HRESULT E_FAIL has been returned from a call to a COM component

hello every one i see this error some times when i designed the page and close the program and came back.but this error do not stop debugging the page and hide all controls is my page and i cant use smart tag and see the controls.what should i do?

Subquery returned more than 1 value

SELECT (SELECT fare_amount FROM fare_tab WHERE (class_code = 'ECO')) AS Economy, (SELECT fare_amount FROM fare_tab AS f2 WHERE (class_code = 'TOU')) AS Tourist FROM fare_tab AS f1 I always received an error of: Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression. How can I solve this?

The remote server returned an error: (550) File unavailable (e.g., file not found, no access).

Hi.   I have read the other threads regarding this but they do not solve my problem. All i am trying to do is upload a file from the webserver onto another server via FTP. But i get the above error and am at my wits end as to why.   below is the code:   Dim fs As New FileStream("H:\Visual Studio 2005\Websites\Website1\testfile.txt", FileMode.Open) Dim filecontents(fs.Length) As Byte fs.Read(filecontents, 0, fs.Length)   Dim remotePath As String = "ftp://elonwactd.uk.ml.com/apps/files/IPBHVGTRADE/QA5/in/testfile.txt" Dim ftp As FtpWebRequest = FtpWebRequest.Create(remotePath) ftp.Credentials = New System.Net.NetworkCredential("user1", "passwd1") ftp.KeepAlive = False ftp.UseBinary = True   ' (have tried UploadFile as well instead of UploadFileWithUniqueName) ftp.Method = WebRequestMethods.Ftp.UploadFileWithUniqueName     fs.Close()   ftp.GetRequestStream.Write(filecontents, 0, filecontents.Length) ftp.GetRequestStream.Close() ftp.GetResponse.Close()     Below is the stack trace that i get. [WebException: The remote server returned an error: (550) File unavailable (e.g., file not found, no access).]   System.Net.FtpWebRequest.SyncRequestCallback(Object obj) +321   System.Net.FtpWebRequest.RequestCallback(Object obj) +19   System.Net.CommandStream.Abort(Exception e) +163   System.Net.FtpWebRequest.FinishRequestStage(RequestStage stage) +45

The status code returned from the server was: 500

  I am getting the following eroor , when using the UpdatePanel of Ajax Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server.The status code returned from the server was: 500 To my strange ,the error is thrown not all the time , only in some rare cases which could not be found out . I tried to increase the AsyncPostBackTimeout to 300 which was 60 but i could n't  get the error down  installing the ajax set up in server is must or not ?  We just placed the ajax dlls in the server. Please can anybody help me with right solution.   Regards G Suresh Kumar         
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend