[dba-VB] ADO.Net

jwcolby jwcolby at colbyconsulting.com
Sun Apr 27 22:01:58 CDT 2008


Shamil,

I would like to thank you for taking the time to do this.  Now... I will 
thank you in advance for taking the time to explain it to me.  As 
happened many years ago when you taught me WithEvents in Access, I don't 
know enough to understand what the heck you are doing.

In the absence of any instructions on how to use this thing, I cut and 
pasted the entire (VB) shebang into a class in a Windows Form project. 
It compiled flawlessly and the blank form opened.

Now what?

I hope that you can appreciate my lack of knowledge here.  I have built 
several projects, with (to my pitiful level of expertise) quite 
extensive stuff going on but... there are a lot of concepts in your code 
that I have not used.  Where to start.

I guess where to start is a good spot.  What do I do to cause this to 
run?  Coming from Access I have always started with a form, which I 
promptly place a button on so I can call some function which "starts" 
things.  That form will have class variables if necessary to instantiate 
a supervisor class, the supervisor class will then load recordsets, load 
data into data classes as required etc.  So what I do not understand is 
"what do I call to make this run"?  I see the MainEntry at the bottom 
but do I just call MainEntry from a button?  Does the code belong in a 
class or a plain module?  I assume that if I put it in a class then I 
would have to dim a variable in my form.

Second (I am totally excited about this whole thing!!!) what are the 
replaceable parameters?

Dim connectionString As String = String.Format("Data 
Source={0}\SQLEXPRESS;Initial Catalog={1};User Id={2};Password={3}", 
pcName, dbName, userName, password)

I assume here that pcName gets fed in to {0}?  THAT is cool, and 
demonstrates where I start from in understanding your code.

Third (also exciting!) I have never used threads yet so here we go.  How 
do I debug that?  Can I step through a thread in the same way I step 
through any other code?  Set break points etc.

And finally (for now) it just occurred to me to ask... can you help me 
(online of offline) to modify this example to actually use my own table 
that I need to parse the name for.  I think I can figure out how to 
modify the stuff for the server, database, table etc.  I have done that 
already in my own code for doing this.  I will also worry about the 
parsing code itself, though just for a demo we can just hard code some 
values.


My table Data:

PKID (int32)
OWNERNAME (to be parsed)
FName (parsed)
MName (parsed)
LName (parsed)
NamePrefix (parsed)
NameSuffix (parsed)
Gender (parsed)

If I can modify they example to actually read / write to my table then I 
kill two birds with one stone, learn a bunch of cool new stuff including 
getting it all happening with threads, and get my real work done.

For my real life purposes I am going to have to have a PKStart, PKEnd 
pair which tracks a block (remember I am doing 80 million rows 
eventually), and increment those start/end by the chunk size to repeat 
over and over (eventually).  What I have found convenient in the past 
(and have code already written to do) is write status log files out to 
disk for each block processed.  I write them as XML and include things 
like the start / end PKID, status memo fields, time start / stop and the 
like.  As I said, I have already written that code (I'm not completely 
helpless, though it sometimes appears that way) and sitting out in a 
library ready to use for the logging.  All I would need to do is build 
the specific data class to store the log data for this project.  I will 
handle that.

I will promise to absorb your example if you will promise to take the 
time to help me when I get stuck.  Once I have done so I will then be 
able to apply it to my specific problem and give you back some real life 
timings from my largish database.  I can vary the chunk size from 1k to 
any upward limit we find useful to test.  My experience has been that 
anything above 10K can get problematic, though that was using the bulk 
import widget in past projects.  I was getting timeouts if I went with 
too large a chunk size.

VB.Net is only a small part of my work life, though I would like to make 
it the main part.  I still spend most of my work life stuck in Access, 
maintaining applications I wrote (or inherited) long ago.  While it pays 
the bills I would LOVE to get to the point where I could bang out code 
like this in the short time that it probably took you.

Again thanks for your time and effort and patience.

Shamil Salakhetdinov wrote:
> Here are the sources I promised to publish in my previous post:
> 
> http://smsconsulting.spb.ru/samples/Stats.txt 
> 
> http://smsconsulting.spb.ru/samples/Program.cs.txt 
> 
> http://smsconsulting.spb.ru/samples/Module.vb.txt 
> 
> Your turn, guys, to fix and improve them...
> 
> --
> Shamil
> 

-- 
John W. Colby
www.ColbyConsulting.com



More information about the dba-VB mailing list