I have a problem when trying to clear the database and add a new one at runtime. The error that we recieve is that the 'Login failed for user....'
On our development machines, the code works perfectly, but the release build errors. The main application uses the same connection string as the one passed into stimulsoft.
We've stubbed the code to checked that the connection string is decrypted correctly before passsing to stimulsoft.
Here is the code;
Code: Select all
Private Sub RenderReport(ByVal ReportName As String)
Dim Report As New StiReport
''----load the report
Report.Load(ReportName)
Report.Compile()
'----wind through the report varibales & see if we can find project id
'----if we can, populate it with selectedProjectGUID if we need to
Dim v As StiVariable
If useProjectId Then
For Each v In Report.Dictionary.Variables
If v.Name = "ProjectId" And useProjectId Then
Report("ProjectId") = selectedProjectGUID.ToString
End If
Next
End If
'----get the current connection string
Dim strConn As String = DataAccess.DBUtilities.GetDecryptedDBConnection()
'----clear the data dictionary to make a new connection using the current connection string
'----Clear the list of databases
Report.Dictionary.Databases.Clear()
'----Add the database and specify its name and the connection string
Report.Dictionary.Databases.Add(New StiSqlDatabase("C22", strConn))
'----render the report
Report.Render()
'----show the report in the preview control
Me.stiPreview.Report = Report
End Sub
Stack Trace:
----------------------
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK)
at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject)
at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart)
at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()
at Stimulsoft.Report.Dictionary.StiSqlAdapterService.OpenConnection(IDbConnection connection, StiData data, StiDictionary dictionary)
at Stimulsoft.Report.Dictionary.StiSqlAdapterService.ConnectDataSourceToData(StiDictionary dictionary, StiDataSource dataSource, Boolean loadData)
at Stimulsoft.Report.Dictionary.StiDataSource.Connect(StiDataCollection datas, Boolean loadData)
at Stimulsoft.Report.Dictionary.StiDataSourcesCollection.Connect(StiDataCollection datas, Boolean loadData)
at Stimulsoft.Report.Dictionary.StiDictionary.Connect(Boolean loadData)
at Stimulsoft.Report.Render.StiRenderProvider.ConnectToData(StiReport report)
at Stimulsoft.Report.Render.StiRenderProvider.Render(StiReport report, StiRenderState state)
at Stimulsoft.Report.StiReport.Render(StiRenderState renderState)
at Stimulsoft.Report.StiReport.Render()
at CITSQL.ReportPreview.RenderReport(String ReportName)
at CITSQL.ReportPreview.gridReportList_DoubleClick(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnDoubleClick(EventArgs e)
at C1.Win.C1FlexGrid.C1FlexGridBase.OnDoubleClick(EventArgs e)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at C1.Win.C1FlexGrid.Util.BaseControls.ScrollableControl.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.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Message:
----------------------
Cannot open database "C22" requested by the login. The login failed.
Login failed for user 'DOMAIN\username' '-----this obviously displays the actual domain and user name.
Target Site:
----------------------
Void OnError(System.Data.SqlClient.SqlException, Boolean)
Source:
----------------------
.Net SqlClient Data Provider