OS: Windows 7 64bit
VB: Visual Studio 2010
Oracle Client: 11g
I am developing an application that connects to an Oracle 11g server. I am able to connect to the Oracle server via Oracle SQL Developer, ODBC (in SYSWOW64), and in VB Server Explorer.
I am using the .NET reference Oracle.DataAccess located at: C:\Oracle\product\11.2.0\client_32\ODP.NET\bin\2.x\Oracle.DataAccess.dll
I have tried adding the .DLL files to my bin folder as suggested by other questions and that does not work.
Does anyone have any other suggestions?
When I run my application, I get the following:
Here are the details:
System.TypeInitializationException was unhandled
Message=The type initializer for 'Oracle.DataAccess.Client.OracleConnection' threw an exception.
Source=Oracle.DataAccess
TypeName=Oracle.DataAccess.Client.OracleConnection
StackTrace:
at Oracle.DataAccess.Client.OracleConnection..ctor(String connectionString)
at Orc_Test_1.Form1.Button1_Click(Object sender, EventArgs e) in c:\Visual Studio 2010\Projects\Orc_Test_1\Orc_Test_1\Form1.vb:line 9
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at Orc_Test_1.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: Oracle.DataAccess.Client.OracleException
DataSource=""
ErrorCode=-2147467259
Message=The provider is not compatible with the version of Oracle client
Number=-11
Procedure=""
Source=Oracle Data Provider for .NET
StackTrace:
at Oracle.DataAccess.Client.OracleInit.Initialize()
at Oracle.DataAccess.Client.OracleConnection..cctor()
InnerException:
VB.NET Code:
Imports System.Data
Imports Oracle.DataAccess.Client ' ODP.NET Oracle managed provider
Imports Oracle.DataAccess.Types
Public Class Form1
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim oradb As String = "Data Source=SERVER1;Persist Security Info=True;User ID=username;Password=password;Unicode=True" 'From Server Explorer
'Dim oradb As String = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=Server1.host.net)(PORT=1522))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=Server1))); USER ID = username;Password = password;" 'From TNSnames.ora
Dim conn As New OracleConnection(oradb) '<--- Error happens on this line
conn.Open()
Dim cmd As New OracleCommand
cmd.Connection = conn
cmd.CommandText = "select system_id from schema1.system_impacted where system_name = AWESOME"
cmd.CommandType = CommandType.Text
Dim dr As OracleDataReader = cmd.ExecuteReader()
dr.Read()
Label1.Text = dr.Item("system_id")
conn.Dispose()
End Sub
End Class
I feel your pain, just went through something similar in a deployment situation. You probably have multiple clients installed, and your environment is pulling dlls for older releases (even if you have a latest oracle.dataaccess.dll correctly referenced in your project). Fixing this on your dev environment is one thing, a prod deployment server is another. Not sure what your deployment situation is, but here's what worked for me.
After struggling with trying to upgrade odp.net in existing oracle home, adding new oracle home, etc., I found the easiest way to fix everything is to download the latest odac with xcopy deployment from Oracle, and follow the readme (and see here for an older article on this also). Basically you'll run an install.bat file to setup locally (in separate folder, mine was c:\oracle_odac), then change your project reference to point to the oracle.dataaccess.dll in this new folder (I used 4 instead of 2.x), and add the new folder's bin dirs to front of your path (c:\oracle_odac\bin and c:\oracle_odac\odp.net\bin\4). On your deployment server, you'll just need to copy the entire c:\oracle_odac folder over (via xcopy or however), and setup the path.
That said, I anxiously await the production release of the fully managed odp.net from Oracle (in beta now).
EDIT: Just to add that you can avoid messing with PATHs if you setup in your app or web config file the dllpath. For example:
<configuration>
...
<configSections>
<section name="oracle.dataaccess.client" type="System.Data.Common.DbProviderConfigurationHandler, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
...
<oracle.dataaccess.client>
<settings>
<add name="DllPath" value="c:\oracle_odac\bin"/>
</settings>
</oracle.dataaccess.client>
...
This will override other settings such as registry or machine.config. And it will allow multiple odp.net configurations to exists peacefully, and allow each app to point to the version it needs on the same server.
Usually happens when you're building x64 application which is trying to pick up x32 drivers that doesn't really work.
What you do in this case (and it's quite painful):
Install x32 oracle client to oraclehome1
Install x64 oracle client to oraclehome2
Make sure your application build (x64, x32) is pointed to correct oraclehome. I don't have that code handy, but I believe it is something along the lines of "Home=oraclehome2" in the connection string or similar.
I removed all of the oracle clients that were available in the 'Programs' section of 'Control Panel'. Then I went into the registry searched for 'Oracle' and removed all instances/references of Oracle client(s). After 3 hours of registry removal and a reboot, I installed the 11g client and everything worked as expected.
Note: when searching the registry for "Oracle", there may be references to the VB version of Oracle, or a reference to Crytsal Reports driver for 'Oracle'. I did not remove these. So pay attention to the file location and/or the syntax of the registry item you are deleting.
/Reading. It works.
download ODAC 32/ ODAC 64 bit ,depending upon on the compatibility of OS, VS and oracle 11g .
Use oracle 11g 32,os 32 bit,oracle 32 bit or oracle 64 bit,os 64 bit and oracle 11g 64 bit.
In my experience, after trying tbone's suggestion, playing with PATH env variable and other unsuccessful plays, the solution that worked immediately was to save a copy of the 8 DLLs files listed below RIGHT ON THE SAME FOLDER of the vb.net executable, and then add a reference to Oracle.DataAccess.dll in the same folder.
C:\Users\Legarcia\Documents\Visual Studio 2010\Projects\LabRetention\LabRetention\bin\Debug>dir *.dll
Volume in drive C is OS
Volume Serial Number is 10EC-8C5D
Directory of C:\Users\Legarcia\Documents\Visual Studio 2010\Projects\LabRetention\LabRetention\bin\Debug
09/30/2008 07:57 PM 348,160 msvcr71.dll
10/01/2008 02:22 AM 520,192 oci.dll
10/01/2008 01:56 AM 352,256 ociw32.dll
08/12/2009 07:13 AM 1,011,712 Oracle.DataAccess.dll
09/18/2008 08:47 PM 1,130,496 orannzsbb11.dll
10/01/2008 01:48 AM 868,352 oraocci11.dll
10/01/2008 02:45 AM 117,604,352 oraociei11.dll
08/12/2009 07:21 AM 413,696 OraOps11w.dll
8 File(s) 122,249,216 bytes
0 Dir(s) 238,127,943,680 bytes free
When developing/testing/debuging, the set of DLLs is copied to ..\projects\{Your project}\bin\Debug
e.g.: [C:\Users\Legarcia\Documents\Visual Studio 2010\Projects\LabRetention\LabRetention\bin\Debug]
And when releasing the application for the users just copy the DLLs to the same dir of your EXE
This seems to isolate all other Ora client installations.
The connection string used in the VB.net app is created from the info in TNSNAMES.ORA file found on some other client directory.
Regards.
LE+
Related
I've already looked up this problem and everything I've have found was referring to C# which might be similar to VB.NET in some cases but I couldn't figure out how to use these solutions in VB.net.
So, my problem is that I got that one machine (end-user) with Windows 7 Professional (x64) which throws this error:
System.InvalidOperationException: Nie można zarejestrować elementu
DragDrop. ---> System.Threading.ThreadStateException: Bieżący wątek
musi być ustawiony na tryb jednow1tkowego apartamentu, aby można
było wykonywać wywołania OLE. Upewnij się, że w funkcji Main jest
zaznaczony element STAThreadAttribute.
w System.Windows.Forms.Control.SetAcceptDrops(Boolean accept)
--- Koniec œladu stosu wyj1tków wewnêtrznych ---
w System.Windows.Forms.Control.SetAcceptDrops(Boolean accept)
w System.Windows.Forms.Control.OnHandleCreated(EventArgs e)
w System.Windows.Forms.DataGridView.OnHandleCreated(EventArgs e)
w System.Windows.Forms.Control.WmCreate(Message& m)
w System.Windows.Forms.Control.WndProc(Message& m)
w System.Windows.Forms.DataGridView.WndProc(Message& m)
w System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
w System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
w System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
As part of it is in Polish I will explain it a bit. Basically in the beginning it says
System.InvalidOperationException: DragDrop registration did not
succeed
and as far as I understand it there is some problem with Drag/Drop option in some DataGridView.
My guess is that it happens when running delegate which checks for notifications because that exception is shown on main form start (a bit after starting delegate) and it shows again after some time when the delegate runs again. I checked all forms which are open by this delegate and none of them has AllowDrop enabled for any control. However I'm using DragDrop in other forms which doesn't throw this exception.
My other guess is that it might be a problem on end-user's machine (not the program's problem) as that exception is never thrown on other hosts (most of them are Windows 10 x64, Pro and Home, and one Windows 7 x86 Professional). I use one install file for all those machines.
Other than that I've tried remote debugging with Visual Studio 2013 on that problematic host and that Exception was never thrown. It is only thrown when application is installed (which btw I tried reinstalling).
Any idea how can I get rid of that error?
I have a dacpac file that is used from SQL 2005 to SQL 2016 databases. Our developers have been using SQL 2016 for the past few months, so we are now moving to production with it.
When attempting to upgrade a database (no previous dacpackage) using our .dacpac file, it will give this error below
===================================
Method not found: 'Void Microsoft.SqlServer.TransactSql.ScriptDom.AlterTableAlterColumnStatement.set_Encryption(Microsoft.SqlServer.TransactSql.ScriptDom.ColumnEncryptionDefinition)'. (Microsoft.Data.Tools.Schema.Sql)
------------------------------
Program Location:
at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeploymentPlanGenerator.AlterStatementGenerator.GenerateForSimpleColumn(SqlSimpleColumn oldColumn, SqlSimpleColumn newColumn)
at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeploymentPlanGenerator.AlterStatementGenerator.GenerateAlterTableForColumn(IModelElement oldElement, IModelElement newElement)
at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeploymentPlanGenerator.AlterStatementGenerator.GenerateStatement(IModelElement oldElement, IModelElement newElement)
at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeploymentPlanGenerator.Sql90AlterStatementGenerator.GenerateScriptDom(IModelElement oldElement, IModelElement newElement)
at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeploymentPlanGenerator.DeploymentScriptDomGenerator.GenerateTableAlter(SqlTable sourceTable, SqlTable targetTable)
at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeploymentPlanGenerator.DeploymentScriptDomGenerator.GenerateFragment(Int32 operation, IModelElement element)
at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeploymentPlanGenerator.DeploymentScriptDomGenerator.GenerateSteps(Int32 operation, IModelElement element)
at Microsoft.Data.Tools.Schema.Sql.Deployment.OrderedStepGenerator.Add(DeploymentScriptDomGenerator scriptDom, IModelElement element, Int32 operation)
at Microsoft.Data.Tools.Schema.Sql.Deployment.Analyzers.PlanMediator.BuildDependencyOrderedSteps(Int32 operation, List`1 classOrder, List`1 operationOrder, Dictionary`2 changes, Boolean preserveGraphs, Dictionary`2& relating, Dictionary`2& related)
at Microsoft.Data.Tools.Schema.Sql.Deployment.Analyzers.PlanMediator.BuildOperations()
at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeploymentPlanGenerator.OnGeneratePlan()
at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeploymentPlanGenerator.GeneratePlan(List`1 drops)
at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeployment.BuildPlan()
at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeployment.Controller.CreatePlan()
at Microsoft.SqlServer.Dac.DacServices.<>c__DisplayClass25.<CreateDeploymentArtifactGenerationOperation>b__23(Object operation, CancellationToken token)
at Microsoft.SqlServer.Dac.Operation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context)
at Microsoft.SqlServer.Dac.ReportMessageOperation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context)
at Microsoft.SqlServer.Dac.OperationExtension.Execute(IOperation operation, DacLoggingContext loggingContext, CancellationToken cancellationToken)
at Microsoft.SqlServer.Dac.DacServices.GenerateDeployReport(DacPackage package, String targetDatabaseName, DacDeployOptions options, Nullable`1 cancellationToken)
at Microsoft.SqlServer.Management.Dac.DacWizard.ReviewPlanPage.ActionStepCalculator_DoWork(Object sender, DoWorkEventArgs e)
at System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e)
at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument)
As far as I can tell, we don't have Encryption enabled at all on any of the tables. This is a fresh database. We've even tried recreating it from scratch, but we get the same error once we try to apply the dacpac file.
Does anyone know what I can do to get the server to recognize the set_Encryption method that it seems to be missing? Any suggestions are appreciated.
Edit: I've further determined that it is not a SQL 2016 issue, but rather a SQL Server Management Studio 2016 issue.
I was able to get around this error, by first running the dacpac through SqlPackage.exe. After that- I was able to publish through management studio.
Context:
I have an update query for a Microsoft Access DB that keeps failing. The query works when executed from within my DB, but fails when executed from my CodeFile for my .aspx page.
I have ensured that:
My App_Data folder has write permissions (via IUSR)
My DB is not 'Read Only'
My query syntax is correct
Does anyone have any advice on what I might be missing? Thank you!!
Code:
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.UI.WebControls
Imports System.Data.OleDb
Partial Class jsDB
Inherits System.Web.UI.Page
Private con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; Data Source = C:\Dustin\App_Data\FAQ.accdb")
Public Sub Page_Load(sender as object, e as System.EventArgs)
If request.QueryString("type") = "helpful" Then
Dim cleanID as string
cleanID = request.querystring("id")
If IsNumeric(cint(cleanID)) Then 'Make sure QueryString hasn't been tampered with
Dim sql as string
sql = "UPDATE QUESTION SET helpful=helpful+1 WHERE questionID=" & cleanID
Dim cmd As New OleDbCommand(sql, con)
con.Open()
cmd.ExecuteNonQuery()
con.Close()
Response.write("Success")
else
Response.write("Invalid ID")
end if
else
Response.write("No recognized type")
end If
End Sub
End Class
Error:
Server Error in '/' Application.
Operation must use an updateable query.
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.OleDb.OleDbException: Operation must use an updateable query.
Source Error:
Line 27:
Line 28: con.Open()
Line 29: cmd.ExecuteNonQuery()
Line 30: con.Close()
Line 31:
Source File: C:\Dustin\FAQDB.aspx.vb Line: 29
Stack Trace:
[OleDbException (0x80004005): Operation must use an updateable query.]
System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr) +1102900
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) +247
System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) +189
System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) +58
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) +162
System.Data.OleDb.OleDbCommand.ExecuteNonQuery() +107
jsDB.Page_Load(Object sender, EventArgs e) in C:\Dustin\FAQDB.aspx.vb:29
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
System.Web.UI.Control.OnLoad(EventArgs e) +92
System.Web.UI.Control.LoadRecursive() +54
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +772
This help page addresses the error you are receiving:
https://support.microsoft.com/en-us/kb/175168
It looks like either youre not opening the connection in the right mode (Mode 3 in this case) or the "table" you are updating has conditions which prevent you from updating it. I'd bet though that changing your Mode to 3 will resolve the issue.
There are several things done wrong here that may help you resolve this and other issues in the future.
IsNumeric(cint(cleanID)) - The IsNumeric() on CInt() is irrelevant. The CInt will either return a System.Int32 or an error. You should just do the IsNumeric() and if you want to know if it is an Int32, then do a Int32.TryParse() on it.
Your command should be parameterized to avoid injection and to avoid passing the wrong data type. For example, I don't know if questionID is a string (which makes your syntax wrong) or if it is an int32. But, a parameterized command would and will supply the correct syntax to your SQL. You can find thousands of example on ho to do this so I will not explain it again here.
The last item, and likely the solution, MS Access queries like to end in a semicolon (;). Seems like I have had issues in the past with not having them in my UPDATE commands for MS Access.
As a side-note. MS Access is terrible about handling multiple connections so leaving them open because of errors will cause you HUGE problems. Be sure that all database calls have proper error handling and if you can put them in a USING block, even better.
Shout-out to #Steve for being such a big help on this.
I had several issues here. While I'm sure there are many issues which could produce the error I was experiencing, here's what resolved it for me:
Created a new application pool in IIS and gave this new pool write permissions to my App_Data folder
Assigned this new app pool to my application
Modified the new app pool under advanced settings to allow 32 bit applications
As of right now, the 'Microsoft.ACE.OLEDB.12.0' provider only works as 32-bit. Changing my application pool to allow 32 bit applications resolved the issue.
Thanks all for your input!
I've got a 140mb SQL query to import data to a new database. I file > open the query, and try and execute it but I get:
Exception of type'System.outofmemoryexception' was thrown. (mscorlib)
I got 8gb ram, using <3gb so what can I do?
at System.String.GetStringForStringBuilder(String value, Int32 startIndex, Int32 length, Int32 capacity)
at System.Text.StringBuilder..ctor(String value, Int32 startIndex, Int32 length, Int32 capacity)
at System.Runtime.InteropServices.Marshal.PtrToStringUni(IntPtr ptr)
at Microsoft.SqlServer.Management.UI.VSIntegration.ShellTextBuffer.GetText(Int32 startPosition, Int32 chars)
at Microsoft.SqlServer.Management.UI.VSIntegration.ShellTextBuffer.get_Text()
at Microsoft.SqlServer.Management.UI.VSIntegration.ShellCodeWindowControl.GetSelectedTextSpan()
at Microsoft.SqlServer.Management.UI.VSIntegration.Editors.ScriptEditorControl.GetSelectedTextSpan()
at Microsoft.SqlServer.Management.UI.VSIntegration.Editors.ScriptAndResultsEditorControl.OnExecScript(Object sender, EventArgs a)
Microsoft SQL Server Management Studio 10.50.1600.1
Microsoft Data Access Components (MDAC) 6.1.7600.16385
Microsoft MSXML 3.0 6.0
Microsoft Internet Explorer 9.0.8112.16421
Microsoft .NET Framework 2.0.50727.4952
Operating System 6.1.7600
This is a known issue reported on Microsoft Connect:
http://connect.microsoft.com/SQLServer/feedback/details/269566/sql-server-management-studio-cant-handle-large-files
If you take a look you can see some workarounds such as using SQL CMD to execute and editing in Notepad++.
It does not appear they will be fixing this however.
I am using WinHost.com to host my site. The SQL Database/membership system works perfectly on my local computer, but when uploaded to the server it doesn't work. I've followed all steps correctly. And I have contacted support for my service but it's been over 2weeks and no reply.
I keep getting this error when i try to login or register a new user on my membership page on my site.
Server Error in '/' Application.
--------------------------------------------------------------------------------
Could not find stored procedure 'dbo.aspnet_CheckSchemaVersion'.
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: Could not find stored procedure 'dbo.aspnet_CheckSchemaVersion'.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[SqlException (0x80131904): Could not find stored procedure 'dbo.aspnet_CheckSchemaVersion'.]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +1953274
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +4849707
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +194
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2392
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +204
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +954
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +162
System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +175
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +137
System.Web.Util.SecUtility.CheckSchemaVersion(ProviderBase provider, SqlConnection connection, String[] features, String version, Int32& schemaVersionCheck) +378
System.Web.Security.SqlMembershipProvider.CheckSchemaVersion(SqlConnection connection) +89
System.Web.Security.SqlMembershipProvider.GetPasswordWithFormat(String username, Boolean updateLastLoginActivityDate, Int32& status, String& password, Int32& passwordFormat, String& passwordSalt, Int32& failedPasswordAttemptCount, Int32& failedPasswordAnswerAttemptCount, Boolean& isApproved, DateTime& lastLoginDate, DateTime& lastActivityDate) +815
System.Web.Security.SqlMembershipProvider.CheckPassword(String username, String password, Boolean updateLastLoginActivityDate, Boolean failIfNotApproved, String& salt, Int32& passwordFormat) +105
System.Web.Security.SqlMembershipProvider.CheckPassword(String username, String password, Boolean updateLastLoginActivityDate, Boolean failIfNotApproved) +42
System.Web.Security.SqlMembershipProvider.ValidateUser(String username, String password) +78
System.Web.UI.WebControls.Login.AuthenticateUsingMembershipProvider(AuthenticateEventArgs e) +60
System.Web.UI.WebControls.Login.OnAuthenticate(AuthenticateEventArgs e) +119
System.Web.UI.WebControls.Login.AttemptLogin() +115
System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e) +101
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +118
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +166
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.4200; ASP.NET Version:2.0.50727.4016
Can somebody please tell me why this error has occured (obviously it can't find something...), and how I can fix it?
Thank you all
Bael
Did you run aspnet_regsql.exe against WinHost.com's sql server?
aspnet_regsql.exe -S DBServerName -U DBLogin -P DBPassword -A all -d DBName
If you don't know where to run above command then you can simply run 'aspnet_regsql.exe' executable file.
In order to locate this file open your RUN Command Box by pressing Windows Key + r and put below command in that %windir%\Microsoft.NET\Framework\v4.0.30319 and Hit enter then find 'aspnet_regsql.exe' file. It will open a wizard that you can follow to resolve this error.
This error mostly occurs when you didn't enabled Roles in your asp.net mvc project At starting before aspnet identity table automatically created.
You will need to make sure you run this so that the tables and objects are created on WinHost.com's SQL server.
Open visual studio command prompt from the Visual studio tools folder from the start menu
and type
aspnet_regsql
and follow the wizard to register the database for asp.net membership and role providers.
I've seen this before. The database you are using doesn't have the required database elements for the membership, role management and profile features. So you've got a couple of options:
Copy across the tables, stored procedures & views from your local SQL Server using SQL Management Studio or a similar application
Use the aspnet_regsql.exe tool to install the scripts from anew as per the instructions in this post (I don't believe you can use the tool against a remote database if it's locked down. So you'll have to export the scripts and run them manually)
I have the same problem- i copy/paste connectionString from SQL Object manager in Visual Studio and forget to type Initial Catalog=YourDatabaseName.
Check the schema the stored procedure belongs to on your host - it could be that it's not in the "dbo" schema.
e.g.
if it's within SomeOtherSchema, your call would need to be "SomeOtherSchema.aspnet_CheckSchemaVersion"
I had the exact same error when I had enabled <roleManager> believing I was enabling ASP.NET Identity 2. They are not the same! The <roleManager> enabled an old version of identity management which uses a different table structure to ASP.NET Identity 2 (which doesn't need "enabling" by the way - it's just there).
If you are intentionally using the old role-manager and still getting the error you might be looking at the default localdb instead of your database, in which case you can modify <roleManager> to point at any connection string you want:
<roleManager
enabled="true"
cacheRolesInCookie="true"
defaultProvider="OurSqlRoleProvider"
>
<providers>
<add
connectionStringName="DefaultConnection"
applicationName="/"
name="OurSqlRoleProvider"
type="System.Web.Security.SqlRoleProvider" />
</providers>
</roleManager>
If you are are after using ASP.NET Identity 2, here's an article on it:
http://johnatten.com/2014/04/20/asp-net-mvc-and-identity-2-0-understanding-the-basics/
In short you should recompile the aspnet provider dll using the sql username you were assigned from your hosting.
Download the
http://download.microsoft.com/download/a/b/3/ab3c284b-dc9a-473d-b7e3-33bacfcc8e98/ProviderToolkitSamples.msi
Replace from the source code all the
references to dbo with your hosting
database username
Compile (you need Visual Studio) and
place the
ProviderToolkitSampleProviders.dll in
the Bin folder
In your web.config replace the "type"
attribute of every line with
“Microsoft.Samples.,
ProviderToolkitSampleProviders”
Replace in you local sql server all dbo references with your hosting database username
Export the sql object creation script and run them on the remote database
Copy the records from your local sql table aspnet_SchemaVersions to the remote database
Another option, pheraps simpler to try, is to replace the dbo references in your local sql server database with your hosting database username, then upload and attach your mdf file.
Hope it helps
Thomas
The simplest solution is to add to the web.config file
<modules>
<remove name="RoleManager" />
</modules>
As Gabriel McAdams mentioned, I used aspnet_regsql.exe but because I am using Integrated Security=True in the connection string I used different flags and also note that the -S flag refers to the SQL Server instance name (in my case localhost\SQLEXPRESS) instead of the server name:
C:\Windows\Microsoft.NET\Framework\v4.0.30319>aspnet_regsql -S DBInstanceName -E -A all -d DBName