ORMLite Dialects - ormlite-servicestack

I have followed the answer given to this [question] (http://stackoverflow.com/questions/13691575/servicestack-ormlite-with-mutliple-database-servers), but am still getting a error. The error is:
{System.Data.SqlClient.SqlException (0x80131904): Invalid object name 'dual'.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource1 completion, Int32 timeout, Task& task, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
at ServiceStack.MiniProfiler.Data.ProfiledDbCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()
at ServiceStack.OrmLite.OrmLiteReadExtensions.ExecReader(IDbCommand dbCmd, String sql) in C:\src\ServiceStack.OrmLite\src\ServiceStack.OrmLite\OrmLiteReadExtensions.cs:line 48
at ServiceStack.OrmLite.OrmLiteReadExtensions.GetScalar[T](IDbCommand dbCmd, String sql, Object[] sqlParams) in C:\src\ServiceStack.OrmLite\src\ServiceStack.OrmLite\OrmLiteReadExtensions.cs:line 498
at ServiceStack.OrmLite.Oracle.OracleOrmLiteDialectProvider.GetNextValue(IDbCommand dbCmd, String sequence, Object value)
at ServiceStack.OrmLite.Oracle.OracleOrmLiteDialectProvider.ToInsertRowStatement(Object objWithProperties, IList1 insertFields, IDbCommand dbCommand)
at ServiceStack.OrmLite.OrmLiteDialectProviderBase1.ToInsertRowStatement(Object objWithProperties, IDbCommand command) in C:\src\ServiceStack.OrmLite\src\ServiceStack.OrmLite\OrmLiteDialectProviderBase.cs:line 439
at ServiceStack.OrmLite.OrmLiteWriteExtensions.Insert[T](IDbCommand dbCmd, T[] objs) in C:\src\ServiceStack.OrmLite\src\ServiceStack.OrmLite\OrmLiteWriteExtensions.cs:line 394
at ServiceStack.OrmLite.OrmLiteWriteConnectionExtensions.<>c__DisplayClass421.b__41(IDbCommand dbCmd) in C:\src\ServiceStack.OrmLite\src\ServiceStack.OrmLite\OrmLiteWriteConnectionExtensions.cs:line 164
at ServiceStack.OrmLite.ReadConnectionExtensions.Exec(IDbConnection dbConn, Action1 filter) in C:\src\ServiceStack.OrmLite\src\ServiceStack.OrmLite\Expressions\ReadConnectionExtensions.cs:line 55
at ServiceStack.OrmLite.OrmLiteWriteConnectionExtensions.Insert[T](IDbConnection dbConn, T[] objs) in C:\src\ServiceStack.OrmLite\src\ServiceStack.OrmLite\OrmLiteWriteConnectionExtensions.cs:line 164
at ServiceStack.ServiceInterface.Auth.OrmLiteAuthRepository.<>c__DisplayClass5.<CreateUserAuth>b__4(IDbConnection db)
at ServiceStack.OrmLite.OrmLiteConnectionFactoryExtensions.Run[T](IDbConnectionFactory connectionFactory, Func2 runDbCommandsFn) in C:\src\ServiceStack.OrmLite\src\ServiceStack.OrmLite\OrmLiteConnectionFactory.cs:line 171
at ServiceStack.ServiceInterface.Auth.OrmLiteAuthRepository.CreateUserAuth(UserAuth newUser, String password)
at ServiceStack.ServiceInterface.Auth.RegistrationService.OnPost(Registration request)
at ServiceStack.ServiceInterface.RestServiceBase`1.Post(TRequest request)
ClientConnectionId:55977ae9-775d-474f-a543-d4cdfeb66a0d}
I am setting things up with the following code:
private void ConfigureAuth(Funq.Container container)
{
...
//Create a DB Factory configured to access the UserAuth SQL Server DB
var connStr = appSettings.Get("SQLSERVER_CONNECTION_STRING", //AppHarbor or Local connection string
ConfigUtils.GetConnectionString("UserAuth"));
container.Register<IDbConnectionFactory>(
new AuthDBConnectionFactory(connStr, //ConnectionString in Web.Config
SqlServerOrmLiteDialectProvider.Instance)
{
ConnectionFilter = x => new ProfiledDbConnection(x, Profiler.Current)
});
//Store User Data into the referenced SqlServer database
container.Register<IUserAuthRepository>(c =>
new OrmLiteAuthRepository(c.Resolve<IDbConnectionFactory>())); //Use OrmLite DB Connection to persist the UserAuth and AuthProvider info
var authRepo = (OrmLiteAuthRepository)container.Resolve<IUserAuthRepository>();
...
}
A little later I set up a connection to a vacancy database held on an oracle server:
private void ConfigureVacancies(Funq.Container container)
{
...
var connStr = appSettings.Get ("VACANCIES_CONNECTION_STRING", //AppHarbor or Local connection string
ConfigUtils.GetConnectionString("VacanciesDB"));
var dbFactory = (OrmLiteConnectionFactory)container.Resolve<IDbConnectionFactory>();
dbFactory.RegisterConnection("vacancies", connStr, ServiceStack.OrmLite.Oracle.OracleDialect.Provider);
...
}
The connection to the vacancies database works fine, but when I try to register a user on the auth database I get the error above. It seems to me that it is holding onto the Oracle Dialect?

I've dicovered that the autodispose connection is being used in the connection factory to also set the setGlobalConnection varible:
public void RegisterConnection(string connectionKey, string connectionString, IOrmLiteDialectProvider dialectProvider, bool autoDisposeConnection = true)
{
NamedConnections[connectionKey] = new OrmLiteConnectionFactory(connectionString, autoDisposeConnection, dialectProvider, autoDisposeConnection);
}
Is that intentional? I've modified my code to set autoDisposeConnection to False, this fixes my dialect problem and allows service stack to query Oracle and MS SQL. I've not quite worked out what the consequence of setting autoDisposeConnection to false is. All my tests are passing now though!

Related

System.Data.SqlClient.SqlException: '' is not a recognized built-in function name

Here is the error I am getting:
Server Error in '/pi' Application.
'Dexsys' is not a recognized built-in function name.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: 'Dexsys' is not a recognized built-in function name.
Source Error:
Line 108: Dim dsTop1 As New DataSet
Line 109: Dim daTop1 As New SqlDataAdapter(strSQL3, cnIT3)
Line 110: daTop1.Fill(dsTop1)
Line 111: cnIT3.Close()
Line 112:
Source File: C:\inetpub\wwwroot\pi\admin\rptSummary.aspx.vb Line: 110
Stack Trace:
[SqlException (0x80131904): 'Dexsys' is not a recognized built-in function name.]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +1789294
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +5340642
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +244
System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) +1691
System.Data.SqlClient.SqlDataReader.TryConsumeMetaData() +61
System.Data.SqlClient.SqlDataReader.get_MetaData() +90
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +377
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds) +1421
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite) +177
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) +53
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) +137
System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) +41
System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) +10
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +140
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +316
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +88
admin_history.getTimes() in C:\inetpub\wwwroot\pi\admin\history.aspx.vb:109
admin_history.Page_Load(Object sender, EventArgs e) in C:\inetpub\wwwroot\pi\admin\history.aspx.vb:217
System.Web.UI.Control.OnLoad(EventArgs e) +92
System.Web.UI.Control.LoadRecursive() +54
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +772
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34212
Here is the function causing the probelm:
Private Sub getTimes()
Dim strSQL3 As String = "select datetimestamp, cast(datepart(yyyy, datetimestamp) as varchar(4)) + '-' + cast(datepart(mm, datetimestamp) as varchar(2)) + '-' + cast(datepart(dd, datetimestamp) as varchar(2)) as yyyyddmm, datepart(hh,datetimestamp) * 3600 + datepart(mm,datetimestamp) * 60 as protime, datepart(hh,datetimestamp) * 3600 + datepart(mm,datetimestamp) + 18000 as protimeplus5 from dex_racklabels.dbo.inv_master where recid = " & Session("INVID")
Dim cnIT3 As New SqlConnection
cnIT3.ConnectionString = ConfigurationManager.ConnectionStrings("csracklabels").ConnectionString
cnIT3.Open()
Dim dsTop1 As New DataSet
Dim daTop1 As New SqlDataAdapter(strSQL3, cnIT3)
daTop1.Fill(dsTop1)
cnIT3.Close()
If dsTop1.Tables(0).Rows.Count > 0 Then
Session("intTm1") = dsTop1.Tables(0).Rows(0).Item("protime")
Session("inttm2") = dsTop1.Tables(0).Rows(0).Item("protimeplus5")
Session("yyyyddmm") = dsTop1.Tables(0).Rows(0).Item("yyyyddmm")
Session("datetimestamp") = dsTop1.Tables(0).Rows(0).Item("datetimestamp")
End If
End Sub
So I have tried to google this issue, and it always seems to be that we are passing something stupid over to SQL that is not recognized as a function.... But how am I getting 'Dexsys' when I don't have anything like that in this function?
Also when I cut out that strSQL3 and put it into SQL and run it.. it runs fine... Could it be the where at the end? How can I stop the code and display the value in the variable: Session("INVID")... I am used to just being able to do response.write(Session("INVID")) and then a response.end()...
I have come accross this issue a couple of times, and would really like to understand how to correct it and why it is happening. Thank you.
Figured it out...
1) I can use response.write and response.end lol... Stupid of me for not actually trying that...
2) Dexsys (2015-9-16) was what was in the Session Varaible... hence the error of the built in function!
Hmm i guess that your problem is with you Session("INVID") you could use the debug mode to check the variable name in the Visual Studio or show it in the Debug Session Like
Debug.Writeline(strSQL3)
'or
Console.WriteLine(strSQL3)
You could also wrap the function in Try Catch Exception so you could check better the error that is happenning. You could also get the specific version of the Exception to find more info.
Like this
Try
'your code goes here.
Catch ex As SqlException
throw
End Try

Update to EntityFramework 6 model isn't being reflected when WebAPI Controller is executed

I have added a database view to SQL Server 2012. After this I updated my EntityFramework (v6) model, built and validated it. From the ASP.Net WebAPI (v2) project I removed and added the reference my EntityFramework library to ensure I was referencing this most recent update. The controller has all the correct links to the context and the EF model classes. No errors in referencing the updates I made from this GET method:
public IEnumerable<RTV_DedicationComments> Get(int EntryNum)
{
//var query = from c in context.RTV_GetAllDedicationsNames orderby c.DedicationName where c.DedicationName.StartsWith(Name) select c;
var query = context.RTV_DedicationComments
.Where(d => d.EntryNumber == EntryNum)
.OrderBy(d => d.EntryNumber)
.Select(d => d);
var results = query.ToList();
return results;
}
At runtime the following error is returned on the innerexception:
{"Invalid column name 'PlatEntryNumber'.\r\nCould not use view or function 'dbo.RTV_DedicationComments' because of binding errors."} when the query is executed:
var results = query.ToList();
'PlatEntryNumber' was from the database and EF model prior to the update ut it has been removed and it doesn't show as a field from dbcontext in the controller.
I turned on the SQL Server profiler to see if the query was executing there and it did:
exec sp_executesql N'SELECT
[Project1].[EntryNumber] AS [EntryNumber],
[Project1].[CommentDate] AS [CommentDate],
[Project1].[Comment] AS [Comment],
[Project1].[CommentBy] AS [CommentBy]
FROM ( SELECT
[Extent1].[EntryNumber] AS [EntryNumber],
[Extent1].[CommentDate] AS [CommentDate],
[Extent1].[Comment] AS [Comment],
[Extent1].[CommentBy] AS [CommentBy]
FROM (SELECT
[RTV_DedicationComments].[EntryNumber] AS [EntryNumber],
[RTV_DedicationComments].[CommentDate] AS [CommentDate],
[RTV_DedicationComments].[Comment] AS [Comment],
[RTV_DedicationComments].[CommentBy] AS [CommentBy]
FROM [dbo].[RTV_DedicationComments] AS [RTV_DedicationComments]) AS [Extent1]
WHERE ([Extent1].[EntryNumber] = #p__linq__0) AND (#p__linq__0 IS NOT NULL)
) AS [Project1]
ORDER BY [Project1].[EntryNumber] ASC',N'#p__linq__0 int',#p__linq__0=5943651
What else can I check to remove the remnants of these database object references between the WebAPI and the EF?
Here is the entire stack trace:
System.Data.Entity.Core.EntityCommandExecutionException was unhandled by user code
HResult=-2146232004
Message=An error occurred while executing the command definition. See the inner exception for details.
Source=EntityFramework
StackTrace:
at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
at System.Data.Entity.Core.Objects.Internal.ObjectQueryExecutionPlan.Execute[TResultType](ObjectContext context, ObjectParameterCollection parameterValues)
at System.Data.Entity.Core.Objects.ObjectQuery`1.<>c__DisplayClassb.<GetResults>b__a()
at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
at System.Data.Entity.Core.Objects.ObjectQuery`1.<>c__DisplayClassb.<GetResults>b__9()
at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 operation)
at System.Data.Entity.Core.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
at System.Data.Entity.Core.Objects.ObjectQuery`1.<System.Collections.Generic.IEnumerable<T>.GetEnumerator>b__0()
at System.Lazy`1.CreateValue()
at System.Lazy`1.LazyInitValue()
at System.Lazy`1.get_Value()
at System.Data.Entity.Internal.LazyEnumerator`1.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at RecWebAPI.Controllers.RTV_GetDedicationCommentsController.Get(Int32 PlatEntryNum) in e:\Development Test\RecTaxWebSLN3\RecWebAPI3\Controllers\RTV_GetDedicationCommentsController.cs:line 43
at lambda_method(Closure , Object , Object[] )
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)
InnerException: System.Data.SqlClient.SqlException
HResult=-2146232060
Message=Invalid column name 'PlatEntryNumber'.
Could not use view or function 'dbo.RTV_DedicationComments' because of binding errors.
Source=.Net SqlClient Data Provider
ErrorCode=-2146232060
Class=16
LineNumber=3
Number=207
Procedure=RTV_DedicationComments
Server=mysqlserver
State=1
StackTrace:
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.<>c__DisplayClassb.<Reader>b__8()
at System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TInterceptionContext,TResult](Func`1 operation, TInterceptionContext interceptionContext, Action`1 executing, Action`1 executed)
at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.Reader(DbCommand command, DbCommandInterceptionContext interceptionContext)
at System.Data.Entity.Internal.InterceptableDbCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
InnerException:
The problem was with my WebAPI web.config file. The had a tag pointing to the old database. This is somewhat confusing to me because I thought the EF handled all the connections to the database and therefore no need for the WebAPI to have the database info. It is working now.

DotNetNuke 7.01.01 Cannot change page names: Procedure or function 'SaveTabUrl' expects parameter '#ModifiedByUserID', which was not supplied

i have searched this on google for a while but didn't find it. When i try to change a page name in page management or on the page itself it doesn't work. This exception is thrown:
DotNetNuke.Services.Exceptions.ModuleLoadException: Procedure or function 'SaveTabUrl'
expects parameter '#ModifiedByUserID', which was not supplied. ---> System.Data.SqlClient.SqlException: Procedure or function 'SaveTabUrl' expects parameter '#ModifiedByUserID', which was not supplied. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource1 completion, Int32 timeout, Task& task, Boolean asyncWrite) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at PetaPoco.Database.Execute(String sql, Object[] args) at DotNetNuke.Data.PetaPoco.PetaPocoHelper.ExecuteNonQuery(String connectionString, CommandType type, Int32 timeout, String sql, Object[] args) at DotNetNuke.Data.SqlDataProvider.ExecuteNonQuery(String procedureName, Object[] commandParameters) at DotNetNuke.Data.DataProvider.SaveTabUrl(Int32 tabId, Int32 seqNum, Int32 portalAliasId, Int32 portalAliasUsage, String url, String queryString, String cultureCode, String httpStatus, Boolean isSystem) at DotNetNuke.Entities.Tabs.Internal.TabControllerImpl.SaveTabUrl(TabUrlInfo tabUrl, Int32 portalId, Boolean clearCache) at DotNetNuke.Entities.Tabs.TabController.CreateTabRedirect(TabInfo tab) at DotNetNuke.Entities.Tabs.TabController.CreateTabRedirects(TabInfo tab) at DotNetNuke.Entities.Tabs.TabController.UpdateTab(TabInfo updatedTab) at DotNetNuke.Modules.Admin.Tabs.ManageTabs.SaveTabData(String strAction) at DotNetNuke.Modules.Admin.Tabs.ManageTabs.cmdUpdate_Click(Object Sender, EventArgs e) --- End of inner exception stack trace ---
Thank you for helping, Remco den hartog
It looks to me this is an issue in this specific version of DNN, see the DNN issue tracker:
https://dnntracker.atlassian.net/browse/DNN-27697?jql=text%20~%20%22SaveTabUrl%22
Upgrade to dnn712 or 7.2 will probably solve your issue.

Windows Service SQL timeout exception

I have a Windows service which continuously each 10 seconds queries the SQL Server database table, and I also have a web site which also queries the same database table after 25 seconds.
After some time I get exception - server timeout exception has occurred. I went through stack-overflow site and has done the changes to SQL configuration settings but still I got the same exception. What to do?
Stack Trace
at System.Data.SqlClient.SqlConnection.OnError(SqlException
exception, Boolean breakConnection) at
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
exception, Boolean breakConnection) at
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() at
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,
SqlCommand cmdHandler, SqlDataReader dataStream,
BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject
stateObj) at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData() at
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds,
RunBehavior runBehavior, String resetOptionsString) at
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean
async) at
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
method, DbAsyncResult result) at
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
method) at
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior
behavior, String method) at
System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior
behavior) at
System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
at
Microsoft.Practices.EnterpriseLibrary.Data.Database.DoExecuteReader(DbCommand
command, CommandBehavior cmdBehavior) at
Microsoft.Practices.EnterpriseLibrary.Data.Database.ExecuteReader(DbCommand
command) at
Microsoft.Practices.EnterpriseLibrary.Data.CommandAccessor1.<Execute>d__0.MoveNext()
at System.Collections.Generic.List1..ctor(IEnumerable1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source)
at System.Runtime.Remoting.Messaging.Message.Dispatch(Object target, Boolean fExecuteInContext) at
System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage
msg, Int32 methodPtr, Boolean fExecuteInContext)
Show me the code! timeout exception usually are because you don't close the database connection.
try add the code in the final of algorithm
if (connection.State == System.Data.ConnectionState.Open)
{
connection.Close();
connection.Dispose();
}
If you use to EnterpriseLibrary, try add more time to commandTimeOut
DbCommand dbcommand = database.GetStoredProcCommand("usp_TheStoredProcedureName");
dbcommand.CommandTimeout = 120;

Error on Execution of a SP ASP.NET C#

public DataTable RunProc(String sProcName, SqlParameter[] arrParams)
{
string sClassName = "DBAccess.RunProc";
SqlConnection objSqlConnection = null;
try
{
objSqlConnection = (SqlConnection)OpenConnection();
string sLogMessage="Executing Stored Procedure: ["+ sProcName +"] with Parameters ";
foreach(SqlParameter objParameter in arrParams)
{
sLogMessage+=objParameter.ParameterName+" = ";
sLogMessage+=objParameter.Value+" ";
}
logger.Logns(LogLevel.TraceDetail,sClassName," ",sLogMessage);
SqlCommand objSqlCommand = CreateCommand(sProcName, arrParams,objSqlConnection,null);
objSqlCommand.CommandTimeout=300;
SqlDataAdapter objSQLDataAdapter = new SqlDataAdapter(objSqlCommand);
DataSet objDataSet = new DataSet();
objSQLDataAdapter.Fill(objDataSet);
this.CloseConnection(objSqlConnection);
logger.Logns(LogLevel.TraceDetail,sClassName," ","Success Executing Stored Procedure: ["+ sProcName +"]");
this.CloseConnection(objSqlConnection);
if( objDataSet.Tables.Count>0)
{
return objDataSet.Tables[0];
}
else
{
return null;
}
//SqlParameter p= new SqlParameter("PACCOUNTNUM", IBM.Data.DB2.DB2Type.VarChar, 17, System.Data.ParameterDirection.Input, true, ((System.Byte)(0)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, null);
}
catch(Exception Ex)
{
logger.Logns(LogLevel.TraceDetail,sClassName," ","Error Executing Stored Procedure: ["+ Ex.ToString() +"]");
this.CloseConnection(objSqlConnection);
throw(new Exception(Ex.ToString()));
}
}
The above mentioned code executes successfully in our production enviroment however all of the sudden we start getting Error in our logs
11/04/2011 09:42:46 AM|TraceDetail
|DBAccess.RunProc
| |Error
Executing Stored Procedure:
[System.Threading.ThreadAbortException:
Thread was being aborted. at
SNINativeMethodWrapper.SNIPacketGetConnection(IntPtr
packet) at
System.Data.SqlClient.TdsParserStateObject.ProcessSniPacket(IntPtr
packet, UInt32 error) at
System.Data.SqlClient.TdsParserStateObject.ReadSni(DbAsyncResult
asyncResult, TdsParserStateObject
stateObj) at
System.Data.SqlClient.TdsParserStateObject.ReadPacket(Int32
bytesExpected) at
System.Data.SqlClient.TdsParserStateObject.ReadBuffer()
at
System.Data.SqlClient.TdsParserStateObject.ReadByte()
at
System.Data.SqlClient.TdsParser.Run(RunBehavior
runBehavior, SqlCommand cmdHandler,
SqlDataReader dataStream,
BulkCopySimpleResultSet
bulkCopyHandler, TdsParserStateObject
stateObj) at
System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
at
System.Data.SqlClient.SqlDataReader.get_MetaData()
at
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader
ds, RunBehavior runBehavior, String
resetOptionsString) at
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior
cmdBehavior, RunBehavior runBehavior,
Boolean returnStream, Boolean async)
at
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior,
Boolean returnStream, String method,
DbAsyncResult result) at
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior,
Boolean returnStream, String method)
at
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior
behavior, String method) at
System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior
behavior) at
System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior
behavior) at
System.Data.Common.DbDataAdapter.FillInternal(DataSet
dataset, DataTable[] datatables, Int32
startRecord, Int32 maxRecords, String
srcTable, IDbCommand command,
CommandBehavior behavior) at
System.Data.Common.DbDataAdapter.Fill(DataSet
dataSet, Int32 startRecord, Int32
maxRecords, String srcTable,
IDbCommand command, CommandBehavior
behavior) at
System.Data.Common.DbDataAdapter.Fill(DataSet
dataSet) at
GDCIEngine.Data.PrismDb.DBAccess.RunProc(String
sProcName, SqlParameter[]
arrParams)]
The above mentioned code is used in a Web service which is called by presentation layer on the presentation layer i happen to recive HTTP Timedout however on the backend where the service is actually hosted the above mentioned exception is getting printed as soon as i do an iisreset on backend machine every thing start working as expected this error is showing up every now and then and iisreset being the only solution i have come up to cope up with it any help in this regard would be highly appreciated
Thanks
Regards
Azeem
You're getting the System.Threading.ThreadAbortException exception. It's a classic exception caused by Response.End, Response.Redirect, or Server.Transfer.
Something in your code is code is causing you to attempt to redirect. Possibly a lost database connection?
Unfortunately, the only way to fix this is to debug it or to try to fix it yourself.
Short of debugging (since it's production), you could try throwing log statements in at specific intervals throughout the function to try to narrow down where the problem is. e.g.
logger.Logns(LogLevel.TraceDetail,sClassName," ","Trace point 1")
... do some stuff ...
logger.Logns(LogLevel.TraceDetail,sClassName," ","Trace point 2")
... do some more stuff ...
logger.Logns(LogLevel.TraceDetail,sClassName," ","Trace point 1")
etc. That might be the only way to track this down.

Resources