|
Hello everyone,
I'm in dire need of figuring out the best data structure that would satisfy my needs and yet utilize the power of Parallel programing introduced in VS 2010.
What this data structure should be able to do efficiently is the following:
-be able to contain elements defined as a specific Structure
-handle tons of repetitive iterations and searches over its elements
-handle not so complex math operations
-be able to easily change in size when necessary without putting extra load on the CPU and RAM
-handle being parallelized
Hopefully, I've made myself clear enough.
Any thoughts would be greatly appreciated ...
Agarwaen
|
|
|
|
|
you can apply parallelism easily if your data needs are limited to:
- reading global data (i.e. across all threads) that no thread will be writing to;
- only writing data that is local to the thread.
So you could easily do a global dictionary, created beforehand, and read by all threads; each thread creating its own collection of results; and when they all finish, maybe join all those results.
If your app doesn't satisfy those restrictions, you need thread synchronization, such as locks, in order to avoid one thread reading data at the very moment it is getting modified by another thread (and for most data structures, a modification may temporarily cause an inconsistent, even an invalid, state).
From your (pretty abstract) data requirements I think you want to read data that is changing often, so you need the synchronization. I might have misunderstood though, you'll have to decide for yourself.
The Parallel goodies .NET 4.0 introduced don't provide data access synchronization for you; all they do is launch a number of threads, and wait for them to join. That is thread synchronization, not data synchronization.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Hi All,
I have one Excel sheet "Student.xls", which has different worksheet as "Sheet1","Sheet2"..like that.
Consider now "Sheet1"; it has 3 columns - "Name", "Age", "Sex". All these columns has row entries.
Now I have one access database, "alldata.mdb". It has One table "Record" which has 3 fields as same as column name of Excel sheet-- "Name", "Age", "Sex".
I want to populate this access database with the entries of Excel sheet from "Sheet1".
Can someone let me know how to do this?
I tried this:
// first connected xl datasheet:
Dim filename As String = "C:\Student.xls"
Dim con As String
con = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & filename & ";" & "Extended Properties=Excel 8.0;"
Dim connection As OleDbConnection = New OleDbConnection(con)
connection.Open()
The above Excel connection was succesful, but how to import the data from this excel sheet into the access database.
Please suggest.
Thanks,
R.S.
|
|
|
|
|
|
Good Article
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
|
|
|
|
|
I have gone through this, and I tried to implement somehow. The implementation is as follows:
// first connected xl datasheet:
Dim filename As String = "C:\Student.xls"
Dim con As String
con = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & filename & ";" & "Extended Properties=Excel 8.0;"
Dim connection As OleDbConnection = New OleDbConnection(con)
connection.Open()
// now copying the excel column into access database table columns:
Dim cmd As New OleDbCommand
cmd.Connection = connection
Try
cmd.CommandText = "SELECT * INTO [MS Access;Database=C:\alldata.mdb].[Record] FROM [Sheet1$]"
cmd.ExecuteNonQuery()
connection.Close()
MsgBox("The Import is Compelte")
Catch ex As Exception
MsgBox("Import Failed, correct Column name in the sheet!")
End Try
While executing I am getting following error:
The Microsoft Jet database engine could not find the object 'Sheet1$'. Make sure the object exists and that you spell its name and the path name correctly.
I am using Microsoft office 2007 with Access 2007 database.
Please tell me how to solve this?
Regards,
R.S.
|
|
|
|
|
The first thing to do would be to try and populate a dataset to prove the data is first getting read from Excel.
If you succeed with that then start trying to populate the access table.
I think for experimenting with new code, you are trying to do too much in one step. Start small, bite sized chunks, or you could end up getting confused by it all.
|
|
|
|
|
I am trying this:
Dim ds1 As New DataSet
Dim da As OleDbDataAdapter = New OleDbDataAdapter("SELECT * FROM [Sheet1$]", connection)
da.Fill(ds1)
But getting same error:
The Microsoft Jet database engine could not find the object 'Sheet1$'. Make sure the object exists and that you spell its name and the path name correctly.
|
|
|
|
|
I created a Student.XLSX file with the 3 columns as you stated in your OP.
The code below successfully ran and imported the data to a dataset which was then bound to a DataGridView;
Dim conBuilder As New OleDbConnectionStringBuilder
conBuilder.Provider = "Microsoft.Jet.OLEDB.4.0"
conBuilder.DataSource = "C:\Users\Dave Auld\Desktop\Student.xlsx"
conBuilder.PersistSecurityInfo = False
conBuilder.Add("Extended Properties", "Excel 8.0;HDR=YES;")
Dim con As New OleDbConnection
con.ConnectionString = conBuilder.ConnectionString
Dim com As New OleDbCommand("Select * from [Sheet1$]")
com.Connection = con
Dim da As New OleDbDataAdapter(com)
Dim ds As New DataSet
Dim rowcount As Integer = da.Fill(ds)
DataGridView1.DataSource = ds
DataGridView1.DataMember = ds.Tables(0).TableName
|
|
|
|
|
Hi,
I have copied the data in a new dataset "ds1". Please tell me how to copy this "ds1" contents into Access Database. I am trying with following:
Dim da2 As New OleDbDataAdapter
Dim conn As OleDbConnection
Dim cmd As OleDbCommand = New OleDbCommand()
conn = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\alldata.mdb;")
cmd = New OleDbCommand("SELECT * FROM Denver", con)
da2 = New OleDbDataAdapter(cmd)
da1.Fill(ds1, "Denver")
But not able to populate the Access database.
Can You guide me how to do this??
Thanks,
R.S.
|
|
|
|
|
|
You have to account for the fact that no two scans of the exact same card will result in a pixel-by-pixel equality. Every pixel is going to be a slightly different color than the same pixel in the previous scan.
If all you're doing is OCR'ing the business cards, why even bother comparing two images of the cards and just compare the data that's coming off them?
If you have to compare the images, then you'll have to implement a filter (in C#, not VB.NET!) to process the image to equalize the colors. For example, if you look at the white part of a business card, you'll see a scattering of pixels of different colors, not an even white acrossed all of them. You have to implement a filter to remove all those color variations to generate the nice flat color acrossed all pixels.
Search the articles for "image processing for dummies" and you'll find some good examples by Christian Graus.
Ph, you can't do this in VB.NET. If you wanted any speed at all, it has to be done in C#, or some other managed language that supports pointers. VB.NET doesn't.
|
|
|
|
|
dear dave... all you wroted isnt corect! download the archive which i posted and try to compare two images...
|
|
|
|
|
Dave Kreskowiak wrote: You have to account for the fact that no two scans of the exact same card will result in a pixel-by-pixel equality. Every pixel is going to be a slightly different color than the same pixel in the previous scan.
i know that and understand what you mean so i made:
Private Function CheckPixel(ByVal source_color As Color, ByVal search_color As Color, ByVal tolerancy As Integer) As Boolean
Dim sense As Long
sense = 255 - tolerancy * 5
CheckPixel = (System.Math.Sqrt((Val(source_color.R.ToString) - Val(search_color.R.ToString)) * (Val(source_color.R.ToString) - Val(search_color.R.ToString)) + (Val(source_color.G.ToString) - Val(search_color.G.ToString)) * (Val(source_color.G.ToString) - Val(search_color.G.ToString)) + (Val(source_color.B.ToString) - Val(search_color.B.ToString)) * (Val(source_color.B.ToString) - Val(search_color.B.ToString))) > sense)
End Function
wich is working ok for pixelbypixel search! but i dont want pixelbypixel search or do want i dont know thats why i posted a link to rapidshare file and application with source wich contains my needs!
Dave Kreskowiak wrote: If all you're doing is OCR'ing the business cards, why even bother comparing two images of the cards and just compare the data that's coming off them?
no i am not doing ocr. i have button "start" and then i scan image and compare to an image that is stored to database and detect difference on those two images and pixelbypixel is slow and not good result but with the code for detect difference from link i posted would do what i want! Here are images you can try with the application i posted and see what i want!
ORIGINAL : http://img96.imageshack.us/img96/3540/originalsp.jpg[^]
SCANED : http://img717.imageshack.us/img717/3461/damaged.jpg[^]
COMPARED : http://img32.imageshack.us/img32/5895/comparator.jpg[^]
Dave Kreskowiak wrote: If you have to compare the images, then you'll have to implement a filter (in C#, not VB.NET!) to process the image to equalize the colors. For example, if you look at the white part of a business card, you'll see a scattering of pixels of different colors, not an even white acrossed all of them. You have to implement a filter to remove all those color variations to generate the nice flat color acrossed all pixels.
yes i want compare... look at compared picture!
Dave Kreskowiak wrote: Search the articles for "image processing for dummies" and you'll find some good examples by Christian Graus.
thanks i will!
|
|
|
|
|
Pf course your search is slow! First, you're using GetPixel, which takes an eternity to execute. Second, this code is garbage:
CheckPixel = (System.Math.Sqrt((Val(source_color.R.ToString) - Val(search_color.R.ToString)) * (Val(source_color.R.ToString) - Val(search_color.R.ToString)) + (Val(source_color.G.ToString) - Val(search_color.G.ToString)) * (Val(source_color.G.ToString) - Val(search_color.G.ToString)) + (Val(source_color.B.ToString) - Val(search_color.B.ToString)) * (Val(source_color.B.ToString) - Val(search_color.B.ToString))) > sense)
Your converting each RGB value component, say R, to a string, then back to a value. This is VERY time consuming an completely unnecessary. Not only are you doing it at all, you're doing it several times for each time you use the same value!
The only way you're going to improve performance is to scrap this code and rewrite it in C# and directly access the image data. You cannot do this in VB.NET because it requires the use of unsafe pointers, which VB.NET does not support.
Search the articles for "image processing for dummies" and you'll find a very good series of articles by Christian Graus explaining just how this is done.
|
|
|
|
|
|
i removed video becose of some e-mails i got last 2 hours
|
|
|
|
|
FeRtoll wrote: I concluded from this only one thing, you dont like vb.net annymore and force to the c#!
First, I already told you why you could not do this entirely in VB.NET. Go back and re-read it.
FeRtoll wrote: Dave Kreskowiak wrote:
Visual Developer - Visual Basic
2006, 2007, 2008
But no longer in 2009...
Because I've spent far more time with my son than here. That's all...
FeRtoll wrote: in c# yes, but i am here asking for vb.net!
There is no equivilent in VB.NET. I already told you VB.NET does not support pointers, making writing it in VB.NET impossible.
FeRtoll wrote: I would prefer to learn assembler rather than c#,
Waste your time however you want. C# is so very close to VB.NET, so you know more about it than you realize.
FeRtoll wrote: and how people say it... i am joking!
I'm not...
|
|
|
|
|
Don't worry , be happy!
hey dont get mad, i respect your opinion and help!
|
|
|
|
|
Hello everyone,
I currently have an infragistics ultrawingrid that takes input in a cell and when tabbed, it updates database and refreshes the grid but the tab goes to the next control. I need the tab to go to the next cell. This is not a problem in the designer its a problem with the grid being refreshed in the hard code and it has to be refreshed because other values have dependency on the values being entered. does anyone have any ideas or any reference to how i can achieve this.
Any comment or suggestion is appreciated
|
|
|
|
|
A better place to ask this question is here[^].
|
|
|
|
|
Hi,
How can I find out what type of disc is in the dvd/cd reader.
I found
- System.IO.DriveInfo(driveLetter)
- FileSystemobject with drives
- Directory.GetLogicalDrives
But non of these tells me what type of disc is in the machine. How can I find this?
Jan
|
|
|
|
|
I don't think there's a direct property but System.IO.DriveInfo has Totalsize so you could work it out from that, no?
|
|
|
|
|
|
Press eject
|
|
|
|