|
desanti wrote: This code is working , but when the bindingsource contains too many itmes , is very slow.
Is there any faster way ? Yes, select by primary key instead of an index.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Sorry , I need to get the index of found item in bindingsource.
|
|
|
|
|
Than you will have to deal with a slow bindingsource.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Hi ,
How to change db path from local to server? I just couldn't figure out the right syntax.
\\server01
Public Function ConnectDataBase() As System.Data.OleDb.OleDbConnection
strPathData = MyPath(Application.StartupPath) & "Data\"
strPathImages = MyPath(Application.StartupPath) & "Images\"
Dim strConn As String = _
"Provider = Microsoft.ACE.OLEDB.12.0;"
strConn +=
"Data Source = " & strPathData & "Contact.accdb"
Conn = New OleDb.OleDbConnection(strConn)
' Create Connection
Conn.ConnectionString = strConn
' Return
Return Conn
End Function
modified 25-Mar-19 15:58pm.
|
|
|
|
|
RedPandinus wrote: Application.StartupPath Inspect the content of this variable and then
RedPandinus wrote: strPathData value, it will give you the idea.
Use a UNC path when you replace the values as not all clients will have the drive mapped to the same letter.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
Hi,
How can I search and find records including special or standart characters both at database?
For instance, When I search for word "ğşçişüö" code should find "ğşçişüö" and also "gsısuo".
or vice versa.
|
|
|
|
|
When you store the string in the database, have a second column which stores the string with the accents removed.
When you search, remove the accents from the search string, and search the column without the accents.
How do I remove diacritics (accents) from a string in .NET? - Stack Overflow[^]
Public Shared Function RemoveDiacritics(ByVal text As String) As String
Dim normalizedString As String = text.Normalize(NormalizationForm.FormD)
Dim stringBuilder As New StringBuilder()
For Each c As Char In normalizedString
Dim unicodeCategory As UnicodeCategory = CharUnicodeInfo.GetUnicodeCategory(c)
If unicodeCategory <> UnicodeCategory.NonSpacingMark Then
stringBuilder.Append(c)
End If
Next
Return stringBuilder.ToString().Normalize(NormalizationForm.FormC)
End Function
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Richard you have a Dim statement inside the loop, is there a performance/elegance issue with continually declaring a new variable. I always declare the variables at the start of the method and try never to declare within a loop structure.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
Moving the variable declaration out of the loop produces exactly the same IL, so it won't make any difference to the performance.
I generally prefer to declare variables where they're needed. Since the unicodeCategory variable isn't used outside of the loop, and the value doesn't need to persist between iterations, I think it makes sense to declare it within the loop.
There's some discussion of this on StackOverflow:
.net - Faster to declare variables inside a loop or outside a loop? - Stack Overflow[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Alternatively, look into SoundEx.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
|
Hi,
How to export Access database to Excel with a button click in a VB project? Thank you.
modified 19-Mar-19 7:38am.
|
|
|
|
|
|
whats wrong with this code? throws COM error. I added interop reference. thanks.
{Retrieving the COM class factory for component with CLSID {00020819-0000-0000-C000-000000000046} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).}
Private Sub excel_Click(sender As Object, e As EventArgs) Handles excel.Click
Threading.Thread.CurrentThread.CurrentCulture = Globalization.CultureInfo.CreateSpecificCulture("en-US")
Dim Xa As New Excel.Application
Dim Wb As New Excel.Workbook
Dim Ws As New Excel.Worksheet
Wb = Xa.Workbooks.Add
Ws = Wb.Worksheet("Sheet1")
Ws.Cells(0, 0) = "Column_1"
Ws.Cells(0, 1) = "Column_2"
Ws.Cells(1, 0) = "Value_1"
Ws.Cells(1, 1) = "Value_2"
Xa.Visible = True
Ws = Nothing : Wb = Nothing : Xa = Nothing
End Sub
|
|
|
|
|
The message is telling you that you do not have Excel installed on that system.
|
|
|
|
|
Excel is installed in system
|
|
|
|
|
You can check that the correct CLSID is registered on the system. Run regedit and navigate to KKEY_CLASSES_ROOT/CLSID. You can then check that the GUID above is present.
|
|
|
|
|
Or that message can come up if your app is compiled/running as 64-bit and Office 32-bit is installed.
Or the other way around.
|
|
|
|
|
I double checked and both are x64.
|
|
|
|
|
As I said, use EPPlus[^] instead of Office Interop.
EPPlus will work even if Excel isn't installed. Or if you run into the problem of trying to automate 32-bit Excel from a 64-bit application (or vice-versa).
It will also work in an unattended application like ASP.NET or a Windows service - unlike Office Interop:
Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.
Free programs like LibreOffice will happily open .xlsx files, but won't work with Office Interop. By using EPPlus, you could save the cost of an Office license.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
That's a great way to fix this. Thank you Richard Deeming.
In meantime I managed to generate Excel export with below codes and wanted to share:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim xlApp As Excel.Application
Dim xlWorkBook As Excel.Workbook
Dim xlWorkSheet As Excel.Worksheet
Dim misValue As Object = System.Reflection.Missing.Value
Dim i As Integer
Dim j As Integer
xlApp = New Excel.Application
xlWorkBook = xlApp.Workbooks.Add(misValue)
xlWorkSheet = xlWorkBook.Sheets("Sheet1")
For i = 0 To dgvData.RowCount - 2
For j = 0 To dgvData.ColumnCount - 1
xlWorkSheet.Cells(i + 1, j + 1) = dgvData(j, i).Value.ToString()
Next
Next
xlWorkSheet.Columns.AutoFit()
xlWorkSheet.Rows.AutoFit()
xlWorkSheet.SaveAs("C:\xxx\xxx.xlsx")
xlWorkBook.Close()
xlApp.Quit()
releaseObject(xlApp)
releaseObject(xlWorkBook)
releaseObject(xlWorkSheet)
MessageBox.Show("xxx C:\xxx\xxx.xlsx", "xxx", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub
Private Sub releaseObject(ByVal obj As Object)
Try
System.Runtime.InteropServices.Marshal.ReleaseComObject(obj)
obj = Nothing
Catch ex As Exception
obj = Nothing
Finally
GC.Collect()
End Try
End Sub
End Class
There are 14 columns and around 2000 row at current Access db I use.
It tooks 4-5 mins to generate Excel report with 8th gen i5 processor/16gb ram PC.
|
|
|
|
|
Interesting. So how did you resolve the original problem?
|
|
|
|
|
Hi I actually didnt do anything different than first code block I have shared. I double checked interop .dll and basicly it was there.
|
|
|
|
|
textbox allowing the user to enter more htan one number
|
|
|
|
|
Did you want to describe a problem you're having or ask a question?
What you posted makes no sens and comes across like a fast food order.
|
|
|
|