how Multi query dbase/dbf with library.net IN VB.NET - vb.net

I want to do multi query with dbase/dbf database with .net library.
I don't want to use oledb because my record is three hundred thousand and I want the data table in datagridview.
I need a fast library please recommend?
Thanks
roy
Imports DbfDataReader
Imports System.IO
Public Class Form1
Dim dbfPath = "C:\Users\Administrator\Desktop\IFG.DBF"
Dim options = New DbfDataReaderOptions With {
.SkipDeletedRecords = True,
.Encoding = EncodingProvider.UTF8
}
End Class

Related

How can I improve the performance of this ADO.NET connection object

I have written a simple connection class, to read from an ODBC-compatible database.
The SQLplusConnection class is provided by the DB vendor, and inherits Data.Common.DbConnection
Imports System.Data.Entity
Imports AspenTech.SQLplus
Public Class IP21Connection
Private connection As SQLplusConnection
Public Const SQLPlusISO8601Format = "yyyy-MM-ddTHH:mm:ssZ"
Public Sub New(hostName As String)
Dim connectionStringBuilder = New SQLplusConnectionStringBuilder With {
.Host = hostName
}
connection = New SQLplusConnection(connectionStringBuilder.ConnectionString)
End Sub
Public Function ExecuteSQLCommand(SQLCommand As SQLplusCommand) As DataSet
Dim resultDataSet = New DataSet()
#If DEBUG Then
Debug.WriteLine(SQLCommand.CommandText)
#End If
Using connection
connection.Open()
Dim adapter = New SQLplusDataAdapter(SQLCommand.CommandText, connection)
adapter.Fill(resultDataSet)
End Using
Return resultDataSet
End Function
End Class
However, the performance is awful.
I have run a performance analysis to understand why, and I found out that:
15% of the runtime is DbDataAdapter.Fill()
65% of the runtime is SQLplusConnection.Open()
It is my understanding that ADO.NET does not really open a new connection everytime I call connection.Open(), but rather used a pool, and got the connection from it.
But given that the program spends four times as much time opening the connections to the DB than executing the actual query, I am starting to wonder if I am not missing an important point.
Could you give me any pointers to improve the performance?

Rename files sequentially

with reference to Renaming all files in a folder
on running the below code, get type def errors:
Type 'DirectoryInfo' is not defined
Type 'FileInfo' is not defined
how to resolve these errors. Please suggest.
Dim sourcePath As String = "E:\testrenamerbackup\vbdotnet"
Dim searchPattern As String = "*.doc"
Dim curDir As New DirectoryInfo(sourcePath)
Dim i As Integer = 0
For Each fi As FileInfo In curDir.GetFiles(searchPattern).OrderBy(Function(num) num.CreationTime)
File.Move(fi.FullName, Path.Combine(fi.Directory.FullName, "docFile_" & i & ".doc"))
i += 1
Next
Add Import System.IO on top of your vb.net class file, for example
Imports System
Imports System.IO
Public Class Test
Public Shared Sub Main()
' your code...
End Sub
End Class
System.IO Namespace contains types that allow reading and writing to files and data streams, and types that provide basic file and directory support including DirectoryInfo, FileInfo. by adding Import System.IO you can use those types and methods in the namespace.

Parse solution using DTE Visual Basic

I have to parse my solution to list all files that it is using.
I have created this:
Imports EnvDTE
Imports EnvDTE80
Imports Microsoft.VisualBasic
Imports System.Collections
Public Class C
Implements VisualCommanderExt.ICommand
Sub Run(DTE As EnvDTE80.DTE2, package As Microsoft.VisualStudio.Shell.Package) Implements VisualCommanderExt.ICommand.Run
listing(DTE)
End Sub
Sub listing(DTE As EnvDTE80.DTE2)
Dim prj As Project
Dim prjs As Projects
prjs = DTE.Solution.Projects
For Each prj In prjs
Dim item As String
Dim itemEnum as IEnumerator = prj.GetEnumerator()
itemEnum.Reset()
While itemEnum.MoveNext()
item = itemEnum.Current().FullName
My.Computer.FileSystem.WriteAllText("C:\tmp\list.txt", item, True)
End While
Next
End Sub
End Class
Unfortunately I encounter the Exception:
System.Runtime.InteropServices.COMExcption(0x80020003): Member not found....
My solution has 10 projects.
Navigating projects and files is recursive because they can be nested.
See my articles:
HOWTO: Navigate the files of a solution from a Visual Studio .NET macro or add-in.
HOWTO: Navigate the files of a solution using the IVsHierarchy interface from an add-in.
http://www.visualstudioextensibility.com/articles/add-ins/

Debugging SSIS vb.net Script

I am debugging a SSIS vb.net script in a Visual Studio 2005 SSIS project.
Is there a way to execute just the script without having to start in my control flow? Otherwise I have to work through my other steps and drill down through my Script Task into the Editor into the actual script.
As a side not my script is pretty simple, it just creates a directory if a directory with today's date is not found.
Imports System
Imports System.IO
Imports Microsoft.VisualBasic
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
Public Class ScriptMain
' Checks to see if todays folder exists on sqlzdocs -> if it doesnt it creates it. Else it errors
Public Sub Main()
Dim todaysdate As String = String.Format("{0:yyyyMMdd}", DateTime.Now)
Dim di As IO.DirectoryInfo = New IO.DirectoryInfo("\\MyServer\Path\Current\" + todaysdate )
If di.Exists = True Then
Dts.Variables("User::FolderExists").Value = True
Else
Try
Dim createdirectory As IO.DirectoryInfo = Directory.CreateDirectory(di.ToString)
Catch ex As Exception
Dts.Variables("User::Errors").Value = "Could not create the directory:" + di.ToString
Dts.Variables("User::FolderExists").Value = False
End Try
End If
Dts.TaskResult = Dts.Results.Success
End Sub
End Class
When i was developing ETL modules that had Script tasks, i followed couple of things to help in testing
Logging the Script task execution points - I wrote simple custom module to handle that
Seperated the functions in the script task and created a seperate Vb.net console project. I executed that project and once it was working successfully, i then included the same in the SSIS project.

Opening pdf from Crystal Reports Viewer

Thank you for viewing my question. I am building a project in Visual Studio 2010 using vb and .net. I have a Crystal Reports report that I'm trying to have auto export and open in PDF with a button click. Right now I am using Crystal Reports Viewer in my project which opens the report fine; However, I would like to have it only open in a pdf format. Is there a way to do this?
Note: I'm not here hunting for code. I'm wanting to learn, so if you could just guide me in the right direction, that will be great (if you don't want to provide code)!
Thank you for the help.
Josh
I'm using code from http://www.codeproject.com/Articles/14549/Crystal-Reports-To-PDF-converter-Without-Crystal-R
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Public Class clsCrystalToPDFConverter
Dim ConInfo As New CrystalDecisions.Shared.TableLogOnInfo
Dim oRDoc As New ReportDocument
Dim expo As New ExportOptions
Dim sRecSelFormula As String
Dim oDfDopt As New DiskFileDestinationOptions
Dim strCrystalReportFilePath As String
Dim strPdfFileDestinationPath As String
Public Function SetCrystalReportFilePath(ByVal CrystalReportFileNameFullPath As String)
strCrystalReportFilePath = CrystalReportFileNameFullPath
End Function
Public Function SetPdfDestinationFilePath(ByVal pdfFileNameFullPath As String)
strPdfFileDestinationPath = pdfFileNameFullPath
End Function
Public Function SetRecordSelectionFormula(ByVal recSelFormula As String)
sRecSelFormula = recSelFormula
End Function
Public Function Transfer()
oRDoc.Load(strCrystalReportFilePath) 'loads the crystalreports in to the memory
oRDoc.RecordSelectionFormula = sRecSelFormula 'used if u want pass the query to u r crystal form
oDfDopt.DiskFileName = strPdfFileDestinationPath 'path of file where u want to locate ur PDF
expo = oRDoc.ExportOptions
expo.ExportDestinationType = ExportDestinationType.DiskFile
expo.ExportFormatType = ExportFormatType.PortableDocFormat
expo.DestinationOptions = oDfDopt
oRDoc.SetDatabaseLogon("PaySquare", "paysquare") 'login for your DataBase
oRDoc.Export()
End Function
End Class
You'll need to set the variables to the specifics of your project obviously. These are more than likely the classes and methods you'll be wanting to use however. This should allow you to take your crystal reports viewer file and turn it into something opened by PDF
This works for me.
Dim orpt As CrystalDecisions.CrystalReports.Engine.ReportDocument
orpt = DirectCast(crvInvoice.ReportSource, CrystalDecisions.CrystalReports.Engine.ReportDocument)
orpt.ExportToDisk(ExportFormatType.PortableDocFormat, "PdfFileName.pdf")