I have StratDateTime and EndDateTime fields in the table. I need to compare this two datetime fields and find seconds. I can use DateDiff but there are the following exceptions:
1. Exclude seconds coming from the date which are Saturday and Sunday
2. Exclude seconds coming from time range between 7:01pm and 6:59am
3. Exclude seconds coming from Jan 1st and Jul 4th.
How can I do this?
Using RAISERROR from within a stored prcedure will result in a SQLException being thrown at the client side of a JDBC connection. I am trying to provide a meaningfull error message to be shown to the end user. However, all exceptions thrown will inevitably start with : "[Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]". The following questions then arise :
- Is there a way of configuring SQL Server not to display this header ?
alternatively,
- Is there another way of conveying error messages to the client through JDBC ?
Hi, I´m new to SQL Server, and I´m having the following problem. I have this query:
SELECT P.DIMENSION, P.CUSTACCOUNT, C.NAME AS CUSTOMERNAME, PE.PROJID, P.NAME AS PROJNAME, PE.EMPLID, E.NAME AS EMPLNAME, PE.FECHAASIGNACION, PE.FECHADESASIGNACION FROM PROJVALEMPLPROJSETUP PE, EMPLTABLE E, PROJTABLE P, CUSTTABLE C WHERE PE.PROJID = P.PROJID AND PE.EMPLID = E.EMPLID AND P.CUSTACCOUNT = C.ACCOUNTNUM AND ((PE.FECHAASIGNACION >= '01/01/2006' AND PE.FECHAASIGNACION < '19/09/07') AND PE.FECHADESASIGNACION >= '01/01/2007') ORDER BY P.DIMENSION, P.CUSTACCOUNT, PE.PROJID, PE.EMPLID
When I execute it, I get this error, regarding the date comparison I´m trying:
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
How do I compare a string value to a datetime from the database? Thanks a lot.
I have a datetime variable coming from my ASP.NET application that hasa time portion. I give my users the option to perform an equals,greater than, less than, or between comparison. The trouble comes inthe way the application builds the criteria string. The WHERE clausepassed in is in the format, "(start_dt = '2005/05/16 07:00:00.000')".What I want to do is only compare the date portion of start_dt to thedate portion of the passed in time. Manipulating the start_dt with thebuilt-in SQL functions isn't a problem, but altering the date passed infrom the ASP.NET would be a massive framework change in the app.Is there any way to only compare the date portions of both the SQLfield and the passed in value?Thanks.
if i have a loop that runs through records in a dataset like thisfor(int i=0;i<ds.Tables[0].Rows.Count;++i) and in this loop i have several sql commands that run as a transaction in a try / catch block like : try{ // do stuff}catch{ trans.RollBack();}how can i keep the loop going even if a transaction failed. So the transaction works for each individual row. if row 100 fails for whatever i would like the loop to continue running, do i just simply remove the "throw" and it will continue looping ? my catch block currently looks like catch(Exception ex){transaction.Rollback();activity.Log("Transaction aborted, rolling back. Error Message: " + ex.Message + " Stack Trace: " + ex.StackTrace.ToString());throw; }thanks,mcm
I'm sure that the try part of following code are all executedand the session("isLogin") has set to Truebut it always catch a exceptionand redirect to error1.aspx can't figure it out 1 Try 2 mySqlCon = New SqlConnection(strMySqlCon) 3 mySqlCmd = New SqlCommand(strMySqlCmd, mySqlCon) 4 5 mySqlCon.Open() 6 myDataReader = mySqlCmd.ExecuteReader() 7 8 If myDataReader.Read() = True Then 9 10 11 webPwdMd5 = System.Web.Security.FormsAuthentication. _ 12 HashPasswordForStoringInConfigFile(Me.TextBox1.Text, "MD5") 13 14 If webPwdMd5 = myDataReader.Item("password") Then 15 Session("isLogin") = True 16 'Me.TextBox1.Text = "ppp" 17 Response.Redirect("main.aspx") 18 Else 19 Session("islogin") = False 20 Me.Label1.Visible = True 21 End If 22 Else 23 Session("isLogin") = False 24 Me.Label1.Visible = True 25 End If 26 27 mySqlCon.Close() 28 29 Catch Myexception As Exception 30 Session("isLogin") = False 31 Response.Redirect("error1.aspx") 32 33 Finally 34 35 End Try
I am a novice with SQL, and I am failing to understand an aspect of Transactions. The following is the code I have created, having referred to a handful of resources including MSDN documentation. public void CreateSection(Section section) { string sql = @"INSERT INTO sectiontable (nodeid, title) VALUES (@nodeid, @title) SELECT Scope_Identity() FROM sectiontable"; SqlConnection connection = new SqlConnection(this.connectionString); SqlCommand command = new SqlCommand(sql, connection); command.Parameters.AddWithValue("@nodeid", section.Node.Id); command.Parameters.AddWithValue("@title", section.Title); connection.Open(); SqlTransaction transaction = connection.BeginTransaction(); try { command.Transaction = transaction; object result = command.ExecuteScalar(); if (result == null) throw new DataException("Returned identity was invalid."); section.Id = Convert.ToInt32(result); transaction.Commit(); } catch (Exception exception) { string message = "Could not create section."; try { transaction.Rollback(); message += " Transaction was reversed."; } catch (SqlException booboo) { message += " An exception of type " + booboo.GetType(); message += " occurred while attempting to roll back the transaction."; } // Note: DataAccessException below is a custom class. throw new DataAccessException(message, exception); } finally { connection.Close(); } } What seems clumsy is that we must have connection.Open() outside the try-catch block. The following cannot work, because the compiler notes the "Use of unassigned local variable 'transaction'" at the location shown below: SqlConnection connection = new SqlConnection(this.connectionString); SqlTransaction transaction; try { connection.Open(); transaction = connection.BeginTransaction(); // commands execute transaction.Commit(); } catch (Exception exception) { transaction.Rollback(); // <-- Compiler notes use of unassigned variable. // (First testing the variable does not help.) // handle exception. } finally { connection.Close(); } The following also does not work, as the BeginTransaction() method must be called against an open connection. SqlConnection connection = new SqlConnection(this.connectionString); SqlTransaction transaction = connection.BeginTransaction(); try { connection.Open(); // commands execute transaction.Commit(); } catch (Exception exception) { transaction.Rollback(); // handle exception. } finally { connection.Close(); } So, in MSDN documentation, the connection.Open() method is called outside the try-catch block (as shown in my full code). Yet, that same documentation notes that this method can lead to two types of exceptions. So it seems that the use of transactions forces an exception-throwing method to be used outside of a try-catch block. My question, then: is this unavoidable?
we are converting Informix Stored procedures to SQL Server stored procedures.. In Informix they have handled the exceptions as shown below, ON EXCEPTION LET @l_status = 1; RETURN @l_delete,@l_status; END EXCEPTION
We have to convert this to the corresponding SQL server statements.. How to ahbdle exceptions in SQL Server.
First off, congrats and thank you to everyone at Microsoft for all of the hard work they have put into Sql Server 2005 and .NET 2.0 - it is simply amazing technology.
On that note, I was wondering if it was possible to create my own custom exceptions that I can throw in my stored procedures and then catch in my application code?
For example, say I wanted to create a Custom Sql Exception called "DuplicateEmailInSqlDatabaseTableException" and then, within a stored procedure where data is being attempted to be inserted, I could check for a duplicate email record and then throw the exception. At that point, I would like to be able to catch that exception in my C# data layer and work from there.
Is this possible? I feel like it could be but am unsure where to start.
I am trying to write a query that will only give me the data that is not in both queries. I need a query that will give me the data that is in the first query but not in the second query. I tried a union but that does not work. The date and PosType are important.
SELECT Symbol,PosType,HistDate
FROM EntityView
WHERE Histdate >'01/01/07' and PosType = 'S'
union
SELECT Symbol,PosType,HistDate FROM EntityView
WHERE Histdate >'01/01/07' and PosType = 'S' and EntityCode = 'HIS'
So I have some SQLCLR stored procedures, that use some .NET classes. I have a table in the database for exceptions, and I want to log all exceptions (except SqlExceptions of course) to that table.
SqlParameter param = new SqlParameter("@message", ex.Message);
cmd.Parameters.Add(param);
param = new SqlParameter("@stackTrace", "test");
cmd.Parameters.Add(param);
param = new SqlParameter("@localtime", DateTime.UtcNow);
cmd.Parameters.Add(param);
try
{
cmd.ExecuteNonQuery(); // always throws IOE, as does SqlContext.Pipe.ExecuteAndSend(cmd);
}
catch (InvalidOperationException)
{
return;
}
}
The exception is: _COMPlusExceptionCode = -532459699 (couldn't find anything useful on that)
Ideally I don't want to be passing the connection to my class all the time, which is why I wanted to have overloaded methods, some that take the connection, others that don't, and open their own. Neither scenario works unfortunately.
If I run the code under LogException in my caller class (ExceptionTest) it works fine (I mean doesn't throw this exception, but I can't call from a SqlFunction - different issue, SQLCLR restriction).
I've been trying to debug this for a while now, and I'm running out of ideas, so any suggestion(s) would be highly appreciated.
We are running into problems using CLR stored procedure in SQL Server 2005. We are using a transaction scope (ambient transaction). If an SQL exception with class 16 is thrown, and this exception is directly caught (and handled) then the transaction is somehow no longer valid. Subsequent use of this transaction gives the message "The current transaction cannot be committed and cannot support operations that write to the log file. Rollback the transaction".
Is there a way to gracefully handle the SqlException and continue the transaction?
To preface, I am trying to get a notification in a client side app from SQL Server 2005 (Express) when a datatable changes. The problem is I am getting these exceptions and I have no idea what is causing them, if it is a serious problem, or how to debug it from here.
Here is the setup:
I am working with SqlDependency in .NET 2.0 and running a simple app that just calls start and stop on the dependency object. The result is 3 exceptions in System.Data.Dll
A first chance exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll
Additional information: A severe error occurred on the current command. The results, if any, should be discarded.
Operation cancelled by user.
A first chance exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll
Additional information: A severe error occurred on the current command. The results, if any, should be discarded.'
Operation cancelled by user.
A first chance exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll
Additional information: A severe error occurred on the current command. The results, if any, should be discarded.
Operation cancelled by user.
To duplicate this problem, do the following:
1) Create a database on SQL Server 2005 Express 2) Make sure the database has "ENABLE_BROKER" set. (ALTER DATABASE <DataBase> SET ENABLE_BROKER).
3) Turn on CLR exceptions in your debugger (debug->Exceptions->Common Language Runtime Exceptions)
4) Create a C# windows app. Add the following in form1_load.
I have written security extension for forms authentication. Apparantly every thing is working fine, I can log on to the report server, view reports, etc without any problem. But i see few exceptions in my log files. The following log was generated even before i logged on to the reporting service:
<Header> <Product>Microsoft SQL Server Reporting Services Version 9.00.3042.00</Product> <Locale>en-US</Locale> <TimeZone>West Asia Standard Time</TimeZone> <Path>C:Program FilesMicrosoft SQL ServerMSSQL.4Reporting ServicesLogFilesReportServer__05_26_2007_18_04_56.log</Path> <SystemName>NAVEEDSIDDIQUI</SystemName> <OSName>Microsoft Windows NT 5.1.2600 Service Pack 2</OSName> <OSVersion>5.1.2600.131072</OSVersion> </Header> aspnet_wp!webserver!1e!5/26/2007-18:04:57:: i INFO: Reporting Web Server started aspnet_wp!library!1e!5/26/2007-18:04:57:: i INFO: Initializing ConnectionType to '1' as specified in Configuration file. aspnet_wp!library!1e!5/26/2007-18:04:57:: i INFO: Initializing IsSchedulingService to 'True' as specified in Configuration file. aspnet_wp!library!1e!5/26/2007-18:04:57:: i INFO: Initializing IsNotificationService to 'True' as specified in Configuration file. aspnet_wp!library!1e!5/26/2007-18:04:57:: i INFO: Initializing IsEventService to 'True' as specified in Configuration file. aspnet_wp!library!1e!5/26/2007-18:04:57:: i INFO: Initializing PollingInterval to '10' second(s) as specified in Configuration file. aspnet_wp!library!1e!5/26/2007-18:04:57:: i INFO: Initializing WindowsServiceUseFileShareStorage to 'False' as specified in Configuration file. aspnet_wp!library!1e!5/26/2007-18:04:57:: i INFO: Initializing MemoryLimit to '60' percent as specified in Configuration file. aspnet_wp!library!1e!5/26/2007-18:04:57:: i INFO: Initializing RecycleTime to '720' minute(s) as specified in Configuration file. aspnet_wp!library!1e!5/26/2007-18:04:57:: i INFO: Initializing MaximumMemoryLimit to '80' percent as specified in Configuration file. aspnet_wp!library!1e!5/26/2007-18:04:57:: i INFO: Initializing MaxAppDomainUnloadTime to '30' minute(s) as specified in Configuration file. aspnet_wp!library!1e!5/26/2007-18:04:57:: i INFO: Initializing MaxQueueThreads to '0' thread(s) as specified in Configuration file. aspnet_wp!library!1e!5/26/2007-18:04:57:: i INFO: Initializing IsWebServiceEnabled to 'True' as specified in Configuration file. aspnet_wp!configmanager!1e!5/26/2007-18:04:57:: w WARN: WebServiceAccount is not specified in the config file. Using default: NAVEEDSIDDIQUIASPNET aspnet_wp!library!1e!5/26/2007-18:04:57:: i INFO: Initializing MaxActiveReqForOneUser to '20' requests(s) as specified in Configuration file. aspnet_wp!library!1e!5/26/2007-18:04:57:: i INFO: Initializing MaxScheduleWait to '5' second(s) as specified in Configuration file. aspnet_wp!library!1e!5/26/2007-18:04:57:: i INFO: Initializing DatabaseQueryTimeout to '120' second(s) as specified in Configuration file. aspnet_wp!library!1e!5/26/2007-18:04:57:: i INFO: Initializing ProcessRecycleOptions to '0' as specified in Configuration file. aspnet_wp!library!1e!5/26/2007-18:04:57:: i INFO: Initializing RunningRequestsScavengerCycle to '60' second(s) as specified in Configuration file. aspnet_wp!library!1e!5/26/2007-18:04:57:: i INFO: Initializing RunningRequestsDbCycle to '60' second(s) as specified in Configuration file. aspnet_wp!library!1e!5/26/2007-18:04:57:: i INFO: Initializing RunningRequestsAge to '30' second(s) as specified in Configuration file. aspnet_wp!library!1e!5/26/2007-18:04:57:: i INFO: Initializing CleanupCycleMinutes to '10' minute(s) as specified in Configuration file. aspnet_wp!library!1e!5/26/2007-18:04:57:: i INFO: Initializing DailyCleanupMinuteOfDay to default value of '120' minutes since midnight because it was not specified in Configuration file. aspnet_wp!library!1e!5/26/2007-18:04:57:: i INFO: Initializing WatsonFlags to '1064' as specified in Configuration file. aspnet_wp!library!1e!5/26/2007-18:04:57:: i INFO: Initializing WatsonDumpOnExceptions to 'Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException,Microsoft.ReportingServices.Modeling.InternalModelingException' as specified in Configuration file. aspnet_wp!library!1e!5/26/2007-18:04:57:: i INFO: Initializing WatsonDumpExcludeIfContainsExceptions to 'System.Data.SqlClient.SqlException,System.Threading.ThreadAbortException' as specified in Configuration file. aspnet_wp!library!1e!5/26/2007-18:04:57:: i INFO: Initializing SecureConnectionLevel to '0' as specified in Configuration file. aspnet_wp!library!1e!5/26/2007-18:04:57:: i INFO: Initializing DisplayErrorLink to 'True' as specified in Configuration file. aspnet_wp!library!1e!5/26/2007-18:04:57:: i INFO: Initializing WebServiceUseFileShareStorage to 'False' as specified in Configuration file. aspnet_wp!resourceutilities!1e!5/26/2007-18:04:57:: i INFO: Reporting Services starting SKU: Developer aspnet_wp!resourceutilities!1e!5/26/2007-18:04:57:: i INFO: Evaluation copy: 0 days left aspnet_wp!runningjobs!1e!5/26/2007-18:04:57:: i INFO: Database Cleanup (Web Service) timer enabled: Next Event: 600 seconds. Cycle: 600 seconds aspnet_wp!runningjobs!1e!5/26/2007-18:04:57:: i INFO: Running Requests Scavenger timer enabled: Next Event: 60 seconds. Cycle: 60 seconds aspnet_wp!runningjobs!1e!5/26/2007-18:04:57:: i INFO: Running Requests DB timer enabled: Next Event: 60 seconds. Cycle: 60 seconds aspnet_wp!runningjobs!1e!5/26/2007-18:04:57:: i INFO: Memory stats update timer enabled: Next Event: 60 seconds. Cycle: 60 seconds aspnet_wp!library!1e!05/26/2007-18:04:58:: e ERROR: Throwing Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException: An internal error occurred on the report server. See the error log for more details., ; Info: Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException: An internal error occurred on the report server. See the error log for more details. ---> System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.ReportingServices.WebServer.WebServiceHelper.ConstructRSServiceObjectFromSecurityExtension() at Microsoft.ReportingServices.WebServer.Global.ConstructRSServiceFromRequest(String item) at Microsoft.ReportingServices.WebServer.Global.get_Service() at Microsoft.ReportingServices.WebServer.Global.DispatchRequest(Boolean& transferedToViewerPage) at Microsoft.ReportingServices.WebServer.Global.Application_AuthenticateRequest(Object sender, EventArgs e) --- End of inner exception stack trace --- aspnet_wp!library!1e!05/26/2007-18:05:06:: i INFO: Exception dumped to: C:Program FilesMicrosoft SQL ServerMSSQL.4Reporting ServicesLogFiles flags= ReferencedMemory, AllThreads, SendToWatson aspnet_wp!library!1e!05/26/2007-18:05:06:: i INFO: Catalog SQL Server Edition = Developer aspnet_wp!library!1e!05/26/2007-18:05:07:: e ERROR: Throwing Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException: An internal error occurred on the report server. See the error log for more details., ; Info: Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException: An internal error occurred on the report server. See the error log for more details. ---> System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.ReportingServices.WebServer.WebServiceHelper.ConstructRSServiceObjectFromSecurityExtension() at Microsoft.ReportingServices.WebServer.Global.ConstructRSServiceFromRequest(String item) at Microsoft.ReportingServices.WebServer.Global.get_Service() at Microsoft.ReportingServices.WebServer.Global.DispatchRequest(Boolean& transferedToViewerPage) at Microsoft.ReportingServices.WebServer.Global.Application_AuthenticateRequest(Object sender, EventArgs e) --- End of inner exception stack trace --- aspnet_wp!library!1e!05/26/2007-18:05:07:: i INFO: Exception dumped to: C:Program FilesMicrosoft SQL ServerMSSQL.4Reporting ServicesLogFiles flags= ReferencedMemory, AllThreads, SendToWatson aspnet_wp!library!1!05/26/2007-18:05:19:: Call to GetPermissionsAction(/). aspnet_wp!library!1!05/26/2007-18:05:19:: Call to GetPropertiesAction(/, PathBased). aspnet_wp!library!1!05/26/2007-18:05:20:: Call to GetSystemPermissionsAction(). aspnet_wp!library!1!05/26/2007-18:05:20:: Call to ListChildrenAction(/, False). aspnet_wp!library!1!05/26/2007-18:05:20:: Call to GetSystemPropertiesAction(). aspnet_wp!library!1!05/26/2007-18:05:20:: Call to GetSystemPropertiesAction(). aspnet_wp!library!c!05/26/2007-18:05:29:: Call to GetPermissionsAction(/Reports). aspnet_wp!library!c!05/26/2007-18:05:29:: Call to GetPropertiesAction(/Reports, PathBased). aspnet_wp!library!c!05/26/2007-18:05:29:: Call to GetSystemPermissionsAction(). aspnet_wp!library!c!05/26/2007-18:05:29:: Call to ListChildrenAction(/Reports, False). aspnet_wp!library!c!05/26/2007-18:05:29:: Call to GetSystemPropertiesAction(). aspnet_wp!library!c!05/26/2007-18:05:29:: Call to GetSystemPropertiesAction(). aspnet_wp!library!1!05/26/2007-18:05:32:: Call to GetPermissionsAction(/Reports/Balance). aspnet_wp!library!1!05/26/2007-18:05:32:: Call to GetSystemPropertiesAction(). aspnet_wp!library!1!05/26/2007-18:05:32:: Call to GetPropertiesAction(/Reports/Balance, PathBased). aspnet_wp!library!1!05/26/2007-18:05:33:: Call to GetSystemPermissionsAction(). aspnet_wp!library!1!05/26/2007-18:05:33:: Call to GetPropertiesAction(/Reports/Balance, PathBased). aspnet_wp!library!1!05/26/2007-18:05:34:: Call to ListEventsAction(). aspnet_wp!library!1!05/26/2007-18:05:34:: Unhandled exception was caught: System.Web.HttpParseException: Could not load type 'Vantage.VantageILM.RSExtensionLibrary.Logon'. ---> System.Exception: Could not load type 'Vantage.VantageILM.RSExtensionLibrary.Logon'. ---> System.Exception: Could not load type 'Vantage.VantageILM.RSExtensionLibrary.Logon'. ---> System.Web.HttpException: Could not load type 'Vantage.VantageILM.RSExtensionLibrary.Logon'. at System.Web.UI.TemplateParser.GetType(String typeName, Boolean ignoreCase, Boolean throwOnError) at System.Web.UI.TemplateParser.ProcessInheritsAttribute(String baseTypeName, String codeFileBaseTypeName, String src, Assembly assembly) at System.Web.UI.TemplateParser.PostProcessMainDirectiveAttributes(IDictionary parseData) --- End of inner exception stack trace --- at System.Web.UI.TemplateParser.ProcessException(Exception ex) at System.Web.UI.TemplateParser.PostProcessMainDirectiveAttributes(IDictionary parseData) at System.Web.UI.PageParser.PostProcessMainDirectiveAttributes(IDictionary parseData) at System.Web.UI.TemplateParser.ProcessMainDirective(IDictionary mainDirective) at System.Web.UI.TemplateControlParser.ProcessMainDirective(IDictionary mainDirective) at System.Web.UI.PageParser.ProcessMainDirective(IDictionary mainDirective) at System.Web.UI.TemplateParser.ProcessDirective(String directiveName, IDictionary directive) at System.Web.UI.BaseTemplateParser.ProcessDirective(String directiveName, IDictionary directive) at System.Web.UI.TemplateControlParser.ProcessDirective(String directiveName, IDictionary directive) at System.Web.UI.PageParser.ProcessDirective(String directiveName, IDictionary directive) at System.Web.UI.TemplateParser.ParseStringInternal(String text, Encoding fileEncoding) --- End of inner exception stack trace --- at System.Web.UI.TemplateParser.ProcessException(Exception ex) at System.Web.UI.TemplateParser.ParseStringInternal(String text, Encoding fileEncoding) at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding) --- End of inner exception stack trace --- at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding) at System.Web.UI.TemplateParser.ParseFile(String physicalPath, VirtualPath virtualPath) at System.Web.UI.TemplateParser.ParseInternal() at System.Web.UI.TemplateParser.Parse() at System.Web.Compilation.BaseTemplateBuildProvider.get_CodeCompilerType() at System.Web.Compilation.BuildProvider.GetCompilerTypeFromBuildProvider(BuildProvider buildProvider) at System.Web.Compilation.BuildProvidersCompiler.ProcessBuildProviders() at System.Web.Compilation.BuildProvidersCompiler.PerformBuild() at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean noAssert) at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp, Boolean noAssert) at System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath) at System.Web.UI.PageHandlerFactory.System.Web.IHttpHandlerFactory2.GetHandler(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath) at System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig) at System.Web.HttpApplication.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) aspnet_wp!library!1!05/26/2007-18:05:34:: e ERROR: Throwing Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException: An internal error occurred on the report server. See the error log for more details., ; Info: Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException: An internal error occurred on the report server. See the error log for more details. ---> System.Web.HttpParseException: Could not load type 'Vantage.VantageILM.RSExtensionLibrary.Logon'. ---> System.Exception: Could not load type 'Vantage.VantageILM.RSExtensionLibrary.Logon'. ---> System.Exception: Could not load type 'Vantage.VantageILM.RSExtensionLibrary.Logon'. ---> System.Web.HttpException: Could not load type 'Vantage.VantageILM.RSExtensionLibrary.Logon'. at System.Web.UI.TemplateParser.GetType(String typeName, Boolean ignoreCase, Boolean throwOnError) at System.Web.UI.TemplateParser.ProcessInheritsAttribute(String baseTypeName, String codeFileBaseTypeName, String src, Assembly assembly) at System.Web.UI.TemplateParser.PostProcessMainDirectiveAttributes(IDictionary parseData) --- End of inner exception stack trace --- at System.Web.UI.TemplateParser.ProcessException(Exception ex) at System.Web.UI.TemplateParser.PostProcessMainDirectiveAttributes(IDictionary parseData) at System.Web.UI.PageParser.PostProcessMainDirectiveAttributes(IDictionary parseData) at System.Web.UI.TemplateParser.ProcessMainDirective(IDictionary mainDirective) at System.Web.UI.TemplateControlParser.ProcessMainDirective(IDictionary mainDirective) at System.Web.UI.PageParser.ProcessMainDirective(IDictionary mainDirective) at System.Web.UI.TemplateParser.ProcessDirective(String directiveName, IDictionary directive) at System.Web.UI.BaseTemplateParser.ProcessDirective(String directiveName, IDictionary directive) at System.Web.UI.TemplateControlParser.ProcessDirective(String directiveName, IDictionary directive) at System.Web.UI.PageParser.ProcessDirective(String directiveName, IDictionary directive) at System.Web.UI.TemplateParser.ParseStringInternal(String text, Encoding fileEncoding) --- End of inner exception stack trace --- at System.Web.UI.TemplateParser.ProcessException(Exception ex) at System.Web.UI.TemplateParser.ParseStringInternal(String text, Encoding fileEncoding) at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding) --- End of inner exception stack trace --- at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding) at System.Web.UI.TemplateParser.ParseFile(String physicalPath, VirtualPath virtualPath) at System.Web.UI.TemplateParser.ParseInternal() at System.Web.UI.TemplateParser.Parse() at System.Web.Compilation.BaseTemplateBuildProvider.get_CodeCompilerType() at System.Web.Compilation.BuildProvider.GetCompilerTypeFromBuildProvider(BuildProvider buildProvider) at System.Web.Compilation.BuildProvidersCompiler.ProcessBuildProviders() at System.Web.Compilation.BuildProvidersCompiler.PerformBuild() at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean noAssert) at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp, Boolean noAssert) at System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath) at System.Web.UI.PageHandlerFactory.System.Web.IHttpHandlerFactory2.GetHandler(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath) at System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig) at System.Web.HttpApplication.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) --- End of inner exception stack trace --- aspnet_wp!library!1!05/26/2007-18:06:05:: i INFO: Exception dumped to: C:Program FilesMicrosoft SQL ServerMSSQL.4Reporting ServicesLogFiles flags= ReferencedMemory, AllThreads, SendToWatson aspnet_wp!library!1!05/26/2007-18:06:05:: Call to GetSystemPropertiesAction(). aspnet_wp!library!c!05/26/2007-18:09:02:: e ERROR: Throwing Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException: An internal error occurred on the report server. See the error log for more details., ; Info: Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException: An internal error occurred on the report server. See the error log for more details. ---> System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.ReportingServices.WebServer.WebServiceHelper.ConstructRSServiceObjectFromSecurityExtension() at Microsoft.ReportingServices.WebServer.Global.ConstructRSServiceFromRequest(String item) at Microsoft.ReportingServices.WebServer.Global.get_Service() at Microsoft.ReportingServices.WebServer.Global.DispatchRequest(Boolean& transferedToViewerPage) at Microsoft.ReportingServices.WebServer.Global.Application_AuthenticateRequest(Object sender, EventArgs e) --- End of inner exception stack trace --- aspnet_wp!library!c!05/26/2007-18:09:36:: i INFO: Exception dumped to: C:Program FilesMicrosoft SQL ServerMSSQL.4Reporting ServicesLogFiles flags= ReferencedMemory, AllThreads, SendToWatson aspnet_wp!library!c!05/26/2007-18:09:36:: e ERROR: Throwing Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException: An internal error occurred on the report server. See the error log for more details., ; Info: Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException: An internal error occurred on the report server. See the error log for more details. ---> System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.ReportingServices.WebServer.WebServiceHelper.ConstructRSServiceObjectFromSecurityExtension() at Microsoft.ReportingServices.WebServer.Global.ConstructRSServiceFromRequest(String item) at Microsoft.ReportingServices.WebServer.Global.get_Service() at Microsoft.ReportingServices.WebServer.Global.DispatchRequest(Boolean& transferedToViewerPage) at Microsoft.ReportingServices.WebServer.Global.Application_AuthenticateRequest(Object sender, EventArgs e) --- End of inner exception stack trace --- aspnet_wp!library!c!05/26/2007-18:10:07:: i INFO: Exception dumped to: C:Program FilesMicrosoft SQL ServerMSSQL.4Reporting ServicesLogFiles flags= ReferencedMemory, AllThreads, SendToWatson aspnet_wp!library!16!5/26/2007-18:14:57:: i INFO: Cleaned 0 batch records, 0 policies, 0 sessions, 0 cache entries, 0 snapshots, 0 chunks, 0 running jobs, 0 persisted streams aspnet_wp!library!a!05/26/2007-18:19:58:: e ERROR: Throwing Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException: An internal error occurred on the report server. See the error log for more details., ; Info: Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException: An internal error occurred on the report server. See the error log for more details. ---> System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.ReportingServices.WebServer.WebServiceHelper.ConstructRSServiceObjectFromSecurityExtension() at Microsoft.ReportingServices.WebServer.Global.ConstructRSServiceFromRequest(String item) at Microsoft.ReportingServices.WebServer.Global.get_Service() at Microsoft.ReportingServices.WebServer.Global.DispatchRequest(Boolean& transferedToViewerPage) at Microsoft.ReportingServices.WebServer.Global.Application_AuthenticateRequest(Object sender, EventArgs e) --- End of inner exception stack trace --- aspnet_wp!library!a!05/26/2007-18:20:29:: i INFO: Exception dumped to: C:Program FilesMicrosoft SQL ServerMSSQL.4Reporting ServicesLogFiles flags= ReferencedMemory, AllThreads, SendToWatson aspnet_wp!library!a!05/26/2007-18:20:29:: e ERROR: Throwing Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException: An internal error occurred on the report server. See the error log for more details., ; Info: Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException: An internal error occurred on the report server. See the error log for more details. ---> System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.ReportingServices.WebServer.WebServiceHelper.ConstructRSServiceObjectFromSecurityExtension() at Microsoft.ReportingServices.WebServer.Global.ConstructRSServiceFromRequest(String item) at Microsoft.ReportingServices.WebServer.Global.get_Service() at Microsoft.ReportingServices.WebServer.Global.DispatchRequest(Boolean& transferedToViewerPage) at Microsoft.ReportingServices.WebServer.Global.Application_AuthenticateRequest(Object sender, EventArgs e) --- End of inner exception stack trace --- aspnet_wp!library!a!05/26/2007-18:21:00:: i INFO: Exception dumped to: C:Program FilesMicrosoft SQL ServerMSSQL.4Reporting ServicesLogFiles flags= ReferencedMemory, AllThreads, SendToWatson aspnet_wp!library!16!5/26/2007-18:24:57:: i INFO: Cleaned 0 batch records, 0 policies, 0 sessions, 0 cache entries, 0 snapshots, 0 chunks, 0 running jobs, 0 persisted streams aspnet_wp!library!1e!05/26/2007-18:27:16:: e ERROR: Throwing Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException: An internal error occurred on the report server. See the error log for more details., ; Info: Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException: An internal error occurred on the report server. See the error log for more details. ---> System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.ReportingServices.WebServer.WebServiceHelper.ConstructRSServiceObjectFromSecurityExtension() at Microsoft.ReportingServices.WebServer.Global.ConstructRSServiceFromRequest(String item) at Microsoft.ReportingServices.WebServer.Global.get_Service() at Microsoft.ReportingServices.WebServer.Global.DispatchRequest(Boolean& transferedToViewerPage) at Microsoft.ReportingServices.WebServer.Global.Application_AuthenticateRequest(Object sender, EventArgs e) --- End of inner exception stack trace --- aspnet_wp!library!1e!05/26/2007-18:27:17:: i INFO: Exception dumped to: C:Program FilesMicrosoft SQL ServerMSSQL.4Reporting ServicesLogFiles flags= ReferencedMemory, AllThreads, SendToWatson aspnet_wp!library!1e!05/26/2007-18:27:17:: e ERROR: Throwing Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException: An internal error occurred on the report server. See the error log for more details., ; Info: Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException: An internal error occurred on the report server. See the error log for more details. ---> System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.ReportingServices.WebServer.WebServiceHelper.ConstructRSServiceObjectFromSecurityExtension() at Microsoft.ReportingServices.WebServer.Global.ConstructRSServiceFromRequest(String item) at Microsoft.ReportingServices.WebServer.Global.get_Service() at Microsoft.ReportingServices.WebServer.Global.DispatchRequest(Boolean& transferedToViewerPage) at Microsoft.ReportingServices.WebServer.Global.Application_AuthenticateRequest(Object sender, EventArgs e) --- End of inner exception stack trace --- aspnet_wp!library!1e!05/26/2007-18:27:17:: i INFO: Exception dumped to: C:Program FilesMicrosoft SQL ServerMSSQL.4Reporting ServicesLogFiles flags= ReferencedMemory, AllThreads, SendToWatson aspnet_wp!library!1e!05/26/2007-18:27:49:: e ERROR: Throwing Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException: An internal error occurred on the report server. See the error log for more details., ; Info: Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException: An internal error occurred on the report server. See the error log for more details. ---> System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.ReportingServices.WebServer.WebServiceHelper.ConstructRSServiceObjectFromSecurityExtension() at Microsoft.ReportingServices.WebServer.Global.ConstructRSServiceFromRequest(String item) at Microsoft.ReportingServices.WebServer.Global.get_Service() at Microsoft.ReportingServices.WebServer.Global.DispatchRequest(Boolean& transferedToViewerPage) at Microsoft.ReportingServices.WebServer.Global.Application_AuthenticateRequest(Object sender, EventArgs e) --- End of inner exception stack trace --- aspnet_wp!library!1e!05/26/2007-18:27:49:: i INFO: Exception dumped to: C:Program FilesMicrosoft SQL ServerMSSQL.4Reporting ServicesLogFiles flags= ReferencedMemory, AllThreads, SendToWatson aspnet_wp!library!1e!05/26/2007-18:27:49:: e ERROR: Throwing Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException: An internal error occurred on the report server. See the error log for more details., ; Info: Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException: An internal error occurred on the report server. See the error log for more details. ---> System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.ReportingServices.WebServer.WebServiceHelper.ConstructRSServiceObjectFromSecurityExtension() at Microsoft.ReportingServices.WebServer.Global.ConstructRSServiceFromRequest(String item) at Microsoft.ReportingServices.WebServer.Global.get_Service() at Microsoft.ReportingServices.WebServer.Global.DispatchRequest(Boolean& transferedToViewerPage) at Microsoft.ReportingServices.WebServer.Global.Application_AuthenticateRequest(Object sender, EventArgs e) --- End of inner exception stack trace ---
In the above logs, only the highlighted area points to my code. Although i dont know why this exception is coming as i have the dll in the bin folder, and the CodeBehind attribute in the logon.aspx field is correct. But i have no clue about the rest of the exceptions. I tried attaching the debugger with aspnet_wp process, but that doesnt help either. Please help me in this regard.
I have written a custom task which writes the details of an error in the windows event log.
I use the on error event to invoke this task.
To simulate the error I try to convert a string into a number. I see that there are multiple as many as 6 messges with different error codes being logged into the windows event log.
They vary from something tangible like number conversion failed to obsure things like thread was being aborted.
Is this normal? to see multiple messages for one type of error.
Can I control this, so that only one message is sent into the windows event log.
(reason is that we have a monitoring software which may raise multiple admin alerts for the same issue).
Hi,I have a connection string in my web.config - to which I then refer to in my code through all my controls, they're all databound to it.Anyway - how do I catch any errors - such as when I want to view the website on a train, if I'm working on it.I don't want it to crash and burn [the site, not the train] - if I dont have access to the sql server.How can I wrap it in a try block!?- How do i then deal with controls which refer to the connection string?One solution I thought of - is to programmatically set all the databinding - and not just with the GUI. As that way I can wrap everything in a try{}catch{} block.Any other - site-wide way of doing this?Thank you,R
Got a weekly problem when our ISeries DB goes down for maintenence i get ODBC connection errors when the SqlDataSource tries to connect. Is there a method I can use to catch the exception? If so, what event from SqlDataSource can i use, and what approach should I take?Thanks in advance!
We are running a COM+ DLL that handles transactions and security with a SQL Server back-end. This project was started in VS 2003, but we just converted it to VS 2005. Since the conversion, creating a number of transactions in a row generates errors at consistent, but moving, locations in the code (i.e. the location where the failure occurs changes when I do things such as add additional try/catch statements, so it is not random but also clearly not associated with any particular line of code).
What is the "correct" way of dealing with exceptions in a data flow script component. i.e. am I supposed to catch all exceptions and then set some failure flag? The reason I ask is I've got a script in a dataflow which is occasionally throwing exceptions when trying to convert an empty string to a decimal. Problem was the package locked up and had to be terminated when the exception was thrown (and not caught in the script)?
The only thing which differentiates this package from others I've created is the data flow has a conditional split which creates 2 seperate paths loading 2 seperate SQL tables - the exception is being thrown in a script on one branch which seems to hand the entire flow
PS I have fixed the script so this doesn't happen, i.e. test if the input string is String.Empty and if so set the _IsNull property.
I am using .NET v2.0 and SqlServer2005 SB in 90 compatibility mode.
From my brief experience it appears that if I try to subscribe to SB with incorrect SQL or wrong names .NET will immediately throw an exception. However, if my code is correct but there is an error on the server (for example incorrect options as per http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=883992&SiteID=1) then SB will immediately fire the notification message but with €œerror€? instead of €œupdate€? content. How do I detect this?
My code is based on the http://msdn2.microsoft.com/en-us/library/3ht3391b(vs.80).aspx example. (I had too much trouble with the SqlDependency class, including overflowing error logs. So unlike the post at http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=903713&SiteID=1 I am NOT receiving an SqlNotificationEventArgs object. I wish I were getting one!) I€™ve included my Listen() method below.
The debug portion of this code gives me message body that looks like the following when everything is good. What should it look like, if for example my SET OPTIONS (first link above) were wrong?
I've been successful at installing a customized SQLexpress using setup.exe /settings template.ini.
What I'd like to do now is see if I can progammatically detect a Firewall on the SQLexpress machine and if there is one to add the exceptions for sqlservr and sqlbrowser programmatically so that the user doesn't have to do anything.
I use the following function (in the BLL) to delete some records: Public Function DeleteStep4Dashboards() As Boolean Try adpDashboards.DeleteStep4Dashboards()Catch ex As Exception Return False End Try Return True End Function How can I catch the sql database errors when deleting the records goes wrong.
Hello guys,I need some ideas on how to handle an exception or a user defined error message.I have a procedure that creates a new user. Lets say if the e-mail address entered is already in use. What are some of the best practices for notifying the user that the e-mail address is already in use?This is what I was thinking....Solution #1--------------My proc will raise an error with a message id that is great than 50000, then my DAL will recognize this is a user defined error and spit back to the user instead of trapping it.Solution #2--------------The proc should have an output param ( @CreationStatus CHAR(1) ).If the @CreationStatus has a value for example "E", I will have lookup the value for "E" in my app and spit back that custom error message. I don't really like this option because it is too concrete.What are some of the ways you deal with this situation?Your suggestions are greatly appreciated.Thank you!
When I first looked at the query behind highlight exceptions, I assumed that PredictCaseLikelihood() was the basis for deciding which rows to flag, but a closer look at the sample data shows this not to be the case. For example, looking at the "Table Analysis Tools Sample" table in the DMAddins_SampleData workbook, ID 11147 is highlighted while ID 11378 is not. Training a cluster model via DMX on this same dataset shows these rows having PredictCaseLikelihood values of 0.165 and 0.158 respectively.
Does anyone have an idea what methodology is used to select the Outlier rows? And once those rows are selected, how are the suspect columns within that row chosen? Appreciate any clues or directions.
I'm setting up a routine to do some reindexing. To get the info I need I'm trying to use the new function. The DB I think is causing the problem does pass DBCC CHECKDB. I'm not sure why I'm getting this but can not find anyone else that is getting this same error.
When I run this....
SELECT *
FROM sys.dm_db_index_physical_stats (NULL, NULL, NULL, NULL, 'detailed')
I get this....
Location: qxcntxt.cpp:954
Expression: !"No exceptions should be raised by this code"
SPID: 236
Process ID: 1060
Msg 0, Level 11, State 0, Line 0
A severe error occurred on the current command. The results, if any, should be discarded.
Msg 0, Level 20, State 0, Line 0
A severe error occurred on the current command. The results, if any, should be discarded.
If I run only for the DB I think is causing the problem I get this...
Msg 0, Level 11, State 0, Line 0
A severe error occurred on the current command. The results, if any, should be discarded.
Msg 0, Level 20, State 0, Line 0
A severe error occurred on the current command. The results, if any, should be discarded.
I came across a frustrating bug last week. Basically, whenever I tried to execute almost any sql query with unnamed parameters (i.e. using "?" instead of "@param_name" in the SQL text), an exception would be thrown.
After trying lots and lots of things and navigating my way through the internals of System.Data.SqlServerCe.dll, I discovered that the method System.Data.SqlServerCe.SqlCeCommand.CreateParameterAccessor(...) has a bug.
The bug is that the private arrays "parameters" and "metadata" are ordered differently, yet at one point in CreateParameterAccessor(...) they are compared using the same index. Here are the two lines: p = this.parameters[ i ]; and MetaData info = metadata[ i ] and then the column data types of "info" & "p" are incorrectly compared in a later method, ValidateDataConversion(...).
So take a step back... how are they ordered differently? From observation, I concluded the following: The "parameters" array is ordered exactly in the order that the DbParameter's were added to the DbCommand object. The "metadata" array is ordered according to the column order of the table in the database.
So what causes the exception? Well, CreateParameterAccessor(...) passes data types from two different columns (one type taken from parameters[ i ] and the other from metadata[ i ]) on to SqlCeType.ValidateDataConversion(...). And, of course, if they differ (e.g. one column is of type DateTime and the other is a SmallInt), an exception is thrown. I've found two workarounds, and both seem to work well. The first is to name the SqlCeParameters (e.g. "SELECT ... WHERE id=@id"). This causes the buggy branch of code to be completely bypassed.
The second is to add the SqlCeParameters in the exact same order as the columns exist in the table you are accessing. Note, I do *not* mean the order that you select the columns (e.g. "SELECT column1, column2, ..."). I mean the actual order of the columns in the database.
I've included my setup and a stack trace below to help if it can.
My setup is: .Net CF 3.5 SqlServer CE 3.5 Visual Studio 2008 Deployed to Pocket PC 2003
Here is the stack trace (note the variables passed to ValidateDataConversion):
Hi, I'm inserting a datetime values into sql server 2000 from c#
SQL server table details Table nameate_test columnname datatype No int date_t DateTime
C# coding SqlConnection connectionToDatabase = new SqlConnection("Data Source=.\SQLEXPRESS;Initial Catalog=testdb;Integrated Security=SSPI"); connectionToDatabase.Open(); DataTable dt1 = new DataTable(); dt1.Columns.Add("no",typeof(System.Int16)); dt1.Columns.Add("date_t", typeof(System.DateTime)); DataRow dr = dt1.NewRow(); dr["no"] = 1; dr["date_t"] = DateTime.Now; dt1.Rows.Add(dr); for(int i=0;i<dt1.Rows.Count;i++) { string str=dt1.Rows["no"].ToString(); DateTime dt=(DateTime)dt1.Rows["date_t"]; string insertQuery = "insert into date_test values(" + str + ",'" + dt + "')"; SqlCommand cmd = new SqlCommand(insertQuery, connectionToDatabase); cmd.ExecuteNonQuery(); MessageBox.Show("saved"); } When I run the above code, data is inserted into the table The value in the date_t column is 2007-07-09 22:10:11 000.The milliseconds value is always 000 only.I need the millisecond values also in date_t column. Is there any conversion needed for millisecond values?