Jump to content
Xtreme .Net Talk

DVader

Members
  • Posts

    7
  • Joined

  • Last visited

Everything posted by DVader

  1. No, as far as I know, they should be identical machines.
  2. Okay, we've run across something a bit odd. I have a Windows forms application, that when it starts, downloads and opens a file (with a .ini file extension) to retrieve some system settings. Private Sub SetupKioskInformation() Dim strKioskString As String = "" Dim strProperty() As String = Nothing Dim strObject As String = "" Dim strValue As String = "" Dim bolbtnWebpageOneSet As Boolean = False Dim bolbtnWebpageTwoSet As Boolean = False Try '-------------------------------------------------------- '- Determine if the Kiosk.ini file exists . . . '-------------------------------------------------------- If File.Exists(strApplicationPath & "kiosk.ini") = True Then '---------------------------------------------------- '- If it does open it in a StreamReader . . . '---------------------------------------------------- srStreamReader = New StreamReader(strApplicationPath & "kiosk.ini") Do While srStreamReader.Peek >= 0 '- Do some stuff . . . Loop Catch ex As Exception WriteToErrorReport(ex.Message, ex.StackTrace, "SetupInformationButtons") Finally If srStreamReader IsNot Nothing Then srStreamReader.Close() srStreamReader.Dispose() End If End Try End Sub And it also opens another file to write some log information to. This file has a .log extension. Private Function WriteLastTransferDate() As Boolean Dim bolWriteLastTransferDate As Boolean = True Try swStreamWriter = New StreamWriter(strApplicationPath & strLastTransferDateFileName, False) swStreamWriter.WriteLine(Now.ToShortDateString) Catch ex As Exception bolWriteLastTransferDate = False WriteToErrorReport(ex.Message, ex.StackTrace, "WriteLastTransferDate") Finally If swStreamWriter IsNot Nothing Then swStreamWriter.Close() swStreamWriter.Dispose() End If End Try Return bolWriteLastTransferDate End Function This application is running on Windows 7 32-bit version. On two of the three machines it is installed on everything works fine. But on the third machine, for some reason, when we minimize or close the application we see each of the above mentioned files open in Notepad. The question I have is why should Notepad be opening for either of those files since I'm not using Notepad?
  3. Okay, changing my SQL connection in the PendingPhotosToUpload function by eliminating the "Initial Catalog=HR54GuardRail;" reference cured the problem. Now I have another question, when running the application on the notebook, I started SQL Server Management Studio and ran the sp_who2 stored procedure. In teh result set I see an entry for the database and a ProgramName of ".Net Sqlclient Data proivder". I've checked my code and we are religiously closing and disposing of conections, so why should that entry be there?
  4. I am developing an application that will run on a notebook computer that as part of its functionality will need to refresh the local database with a version copied down from a network server. The database is in SQL Server Express 2005. When I test my code though I am getting an error message that says... "Exclusive access could not be obtained because the database is in use." As part of the process I need to check to see if there are any pending changes before I allow the user to refresh the local copy of the database. That is the highlighted code below in red. Public Function RefreshLocalDatabase() As Boolean Dim strMessage As String = "" Dim bolPendingDataChanges As Boolean = False Dim bolPendingPhotosToUpload As Boolean = False Dim bolRefreshLocalDatabase As Boolean = False Dim bolErrorOccurred As Boolean = False Try '-------------------------------------------------------- '- First, check to see if there are any pending '- database changes . . . '-------------------------------------------------------- [color="Red"]bolPendingPhotosToUpload = PendingPhotosToUpload()[/color] '-------------------------------------------------------- '- '-------------------------------------------------------- If bolPendingPhotosToUpload = False Then '---------------------------------------------------- '- If there are no pending changes then first make '- a backup copy of the LOCAL database . . . '---------------------------------------------------- If LocalDatabaseBackupCreated() = True Then If CopyProductionDatabaseToNotebook() = True Then If Me.RestoreProductionDatabase = True Then bolErrorOccurred = False Else bolErrorOccurred = True End If Else bolErrorOccurred = True End If Else bolErrorOccurred = True End If If bolErrorOccurred = False Then bolRefreshLocalDatabase = True Else bolRefreshLocalDatabase = False End If Else bolRefreshLocalDatabase = False strMessage = "Unable to Refresh the Local database:" & vbNewLine & vbNewLine If bolPendingPhotosToUpload = True Then strMessage = strMessage & " - There are still photos that need to be uploaded." & vbNewLine & vbNewLine End If MessageBox.Show(strMessage, "Refresh Local Database", MessageBoxButtons.OK, MessageBoxIcon.Information) End If Catch ex As Exception bolRefreshLocalDatabase = False MessageBox.Show(ex.Message & vbCrLf & vbCrLf & ex.StackTrace, "RefreshLocalDatabase", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try Return bolRefreshLocalDatabase MessageBox.Show("Done...RefreshLocalDatabase") End Function If I comment that line of code the process runs to completion with no problem. If I don't I get the error. Here's the code I'm using to check for pending changes... Private Function PendingPhotosToUpload() As Boolean Dim connLocal As New SqlConnection Dim strSelect As String Dim bolPending As Boolean = False Dim cmdSelect As SqlCommand = Nothing Dim sqlDR As SqlDataReader = Nothing Try strSelect = "SELECT Count(*) AS PendingCount " & _ "FROM Segment WHERE PhotosAvailableInd = 1" connLocal = New SqlConnection("Server=(local)\SQLEXPRESS;Initial Catalog=HR54GuardRail;Integrated Security=SSPI") connLocal.Open() cmdSelect = New SqlCommand(strSelect, connLocal) cmdSelect.CommandType = CommandType.Text sqlDR = cmdSelect.ExecuteReader If sqlDR.HasRows = True Then Do While sqlDR.Read If Not sqlDR("PendingCount") Is DBNull.Value Then If CInt(sqlDR("PendingCount")) > 0 Then bolPending = True Else bolPending = False End If End If Loop Else bolPending = False End If Catch ex As Exception bolPending = False MessageBox.Show(ex.Message & vbCrLf & vbCrLf & ex.StackTrace, "PendingPhotosToUpload", MessageBoxButtons.OK, MessageBoxIcon.Error) Finally If Not (sqlDR Is Nothing) Then sqlDR.Close() sqlDR = Nothing End If If Not (cmdSelect Is Nothing) Then cmdSelect.Dispose() cmdSelect = Nothing End If If Not (connLocal Is Nothing) Then If Not (connLocal.State = ConnectionState.Closed) Then connLocal.Close() End If connLocal.Dispose() connLocal = Nothing End If End Try Return bolPending End Function So for some reason there is still a connection to the local database that is preventing the retore process to work. What I don't understand is what I am doing wrong with closing the database connection. Can anyone provide any help?
  5. I'm developing a form that has five textboxes that I bind to a DataTable in a DataSet. Private Sub BindEvent() Try Me.txtEventNbr.DataBindings.Add(New Windows.Forms.Binding("text", dsSafety.Tables("Event"), "EventID")) Me.txtAccidentLocation.DataBindings.Add(New Windows.Forms.Binding("text", dsSafety.Tables("Event"), "LocationDesc")) Me.txtAccidentDate.DataBindings.Add(New Windows.Forms.Binding("text", dsSafety.Tables("Event"), "EventDate")) Me.txtAccidentTime.DataBindings.Add(New Windows.Forms.Binding("text", dsSafety.Tables("Event"), "EventTime")) Me.txtAccidentDesc.DataBindings.Add(New Windows.Forms.Binding("text", dsSafety.Tables("Event"), "EventDesc")) Catch ex As Exception MessageBox.Show(ex.Message & vbCrLf & vbCrLf & ex.StackTrace, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Sub If I change a value of one of the textboxes on the form I expect the Rowstate property for the DataTable the textbox is bound to tobe change to Modified, but that isn't happening. It still indicates that the RowState is Unmodified. Though if I check the value of the column in my DataTable it has the value that I keyed into the textbox (using a messagebox behind a button). I tried adding some additional logic to force an EndCurrentEdit when I change the value of the textbox, but the RowState still says Unmodified. Private Sub txtAccidentLocation_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtAccidentLocation.LostFocus Try Me.BindingContext(dsSafety).EndCurrentEdit() Catch ex As Exception MessageBox.Show(ex.Message & vbCrLf & vbCrLf & ex.StackTrace, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Sub Any ideas on why the Rowstate of the DataTable doesn't change to Modified when changing the value in the textbox?
  6. One thing I should have mentioned in my first post was that this DLL needs to be used from either VB6 or .NET, so will any of those changes impact the DLL's use in a .NET application?
  7. I've written a DLL in VB.NET and I am trying to use it in a VB6 application. When I run the application from either directly in VB6 or from the executable I get the following error message: "Class does not support automation or does not support expected interface." Here's a snapshot of the DLL code: Option Explicit On Imports System Imports Microsoft.Win32 Imports Microsoft.VisualBasic Imports System.IO Imports System.Security.Permissions Imports System.Text Imports CrystalDecisions.Enterprise Imports CrystalDecisions.Enterprise.Viewing Imports CrystalDecisions.Enterprise.Desktop.Report Imports CrystalDecisions.ReportAppServer.Controllers Imports CrystalDecisions.ReportAppServer.ClientDoc Imports CrystalDecisions.ReportAppServer.DataDefModel Imports CrystalDecisions.CrystalReports.TemplateEngine Imports CrystalDecisions.ReportAppServer.ReportDefModel Imports CrystalDecisions.ReportAppServer.CommonObjectModel Imports CrystalDecisions.ReportAppServer.ObjectFactory Imports System.Windows.Forms Imports System.Runtime.InteropServices Public Enum ReportServer As Integer Development = 0 Test = 1 Production = 2 End Enum Public Enum DocumentType As Integer PDF = 0 MSWord = 1 MSExcel = 2 End Enum <GuidAttribute("A366D469-A20A-4224-ACBA-6BDFE219E34A")> _ Public Interface _IBusinessObjectsServer Function RetrieveRepositoryReport(ByVal pReportName As String, _ ByVal Server As ReportServer, _ ByRef pParamList(,) As String, _ ByVal DBUserName As String, _ ByVal DBPassword As String, _ Optional ByVal SQLServer As String = "", _ Optional ByVal Database As String = "") As ReportClientDocument Sub ViewRepositoryReport(ByVal pReportName As String, _ ByVal Server As ReportServer, _ ByRef pParamList(,) As String, _ ByVal DBUserName As String, _ ByVal DBPassword As String, _ Optional ByVal SQLServer As String = "", _ Optional ByVal Database As String = "") Function ExportRepositoryReport(ByVal pReportName As String, _ ByVal Server As ReportServer, _ ByRef pParamList(,) As String, _ ByVal DBUserName As String, _ ByVal DBPassword As String, _ ByVal pPathAndFilename As String, _ ByVal pDocumentType As DocumentType, _ Optional ByVal SQLServer As String = "", _ Optional ByVal Database As String = "") As Boolean End Interface <System.Runtime.InteropServices.ProgId("BusinessObjectsReportServer"), _ ClassInterface(ClassInterfaceType.None), _ GuidAttribute("E1A6A3DF-6843-4899-BB35-5FB782F90056")> _ Public Class BOEReportServer Implements _IBusinessObjectsServer Friend bolShowExportButton As Boolean = False Friend bolShowGroupTreeButton As Boolean = False Friend bolDisplayGroupTree As Boolean = False Friend bolEnableDrillDown As Boolean = False Friend bolShowRefreshButton As Boolean = False Property ShowGroupTreeButton() As Boolean Get Return bolShowGroupTreeButton End Get Set(ByVal Value As Boolean) bolShowGroupTreeButton = Value End Set End Property Property ShowExportButton() As Boolean Get Return bolShowExportButton End Get Set(ByVal Value As Boolean) bolShowExportButton = Value End Set End Property Property DisplayGroupTree() As Boolean Get Return bolDisplayGroupTree End Get Set(ByVal Value As Boolean) bolDisplayGroupTree = Value End Set End Property Property EnableDrillDown() As Boolean Get Return bolEnableDrillDown End Get Set(ByVal Value As Boolean) bolEnableDrillDown = Value End Set End Property Property ShowRefreshButton() As Boolean Get Return bolShowRefreshButton End Get Set(ByVal Value As Boolean) bolShowRefreshButton = Value End Set End Property Public Function RetrieveRepositoryReport(ByVal pReportName As String, _ ByVal Server As ReportServer, _ ByRef pParamList(,) As String, _ ByVal DBUserName As String, _ ByVal DBPassword As String, _ Optional ByVal SQLServer As String = "", _ Optional ByVal Database As String = "") As ReportClientDocument Implements _IBusinessObjectsServer.RetrieveRepositoryReport CODE REMOVED... End Function Public Sub ViewRepositoryReport(ByVal pReportName As String, _ ByVal Server As ReportServer, _ ByRef pParamList(,) As String, _ ByVal DBUserName As String, _ ByVal DBPassword As String, _ Optional ByVal SQLServer As String = "", _ Optional ByVal Database As String = "") Implements _IBusinessObjectsServer.ViewRepositoryReport CODE REMOVED... End Sub Public Function ExportRepositoryReport(ByVal pReportName As String, _ ByVal Server As ReportServer, _ ByRef pParamList(,) As String, _ ByVal DBUserName As String, _ ByVal DBPassword As String, _ ByVal pPathAndFilename As String, _ ByVal pDocumentType As DocumentType, _ Optional ByVal SQLServer As String = "", _ Optional ByVal Database As String = "") As Boolean Implements _IBusinessObjectsServer.ExportRepositoryReport CODE REMOVED... End Function End Class I've checked the "Register for COM Interop" property of the DLL and added the AssemblyKeyFile line to the AssemblyInfo.vb In the VB6 application I've added the DLL to the references. Here's a sample of the VB6 code: Private Sub cmdReturnReport_Click() On Error GoTo Err_cmdReturnReport_Click Dim strParamList(5, 1) As String Dim strReportName As String strReportName = "EventsByPosition" strParamList(0, 0) = "Area" strParamList(0, 1) = "No" strParamList(1, 0) = "Region" strParamList(1, 1) = "No" strParamList(2, 0) = "From-Date" strParamList(2, 1) = "1995-01-01" strParamList(3, 0) = "To-Date" strParamList(3, 1) = "2004-12-31" strParamList(4, 0) = "Event-Type" strParamList(4, 1) = "J;V" strParamList(5, 0) = "@Position" strParamList(5, 1) = "EQUIPMENT MECHAN" '-------------------------------------------------------- '- Display the report . . . '-------------------------------------------------------- Dim oRS As BusinessObjectsReportServer.BOEReportServer [b]Set oRS = New BusinessObjectsReportServer.BOEReportServer[/b] Call oRS.ViewRepositoryReport(strReportName, ReportServer_Development, strParamList, "HS50_Admin", "HS50_Admin") Exit_cmdReturnReport_Click: Exit Sub Err_cmdReturnReport_Click: MsgBox Err.Description & " - " & Err.Number End Sub The bold line above is the one giving the error. When I type in the lines that reference the DLL the intellisense works. So what am I doing wrong?
×
×
  • Create New...