Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Making formless app with ADO.NET, i'm clueless.

Status
Not open for further replies.

rssql

Programmer
Jul 22, 2002
87
US
I have a formless app built with VB2005 Exp.
I'm trying to have it open a database so i can send data with insert statements.

The app is able to open several concurrent IP sockets to receive data, then each socket needs to be able to Insert Into a certain table.

I'm not sure how to proceed.

Do i create a class which establishes the DB connection, then create a public sub that is called by each socket to do inserts?



-------------------
The greatest obstacle to discovery is not ignorance -- it is the illusion of knowledge.
Daniel Boorstin
 
First thought that came to my mind was a module. In the sub main of the module you'll set up an infinite loop that checks a data table for values, writes those values to the database and removes them from the data table.

The module should also have a (thread safe!) method that will add specific values to that data table. You can call that method from your other threads that are handling this network I/O.

-Rick


VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
thanks Rick.
I'm trying to make the transition from VB6 to NET.
I've been putting it off due to the appearent learning curve, and have finally decided to attempt it.

I think i understand what you say, now i just have to figure out how to really do that with NET.

<. .>
0


-------------------
The greatest obstacle to discovery is not ignorance -- it is the illusion of knowledge.
Daniel Boorstin
 
In the Sub Main you will need to:

Establish a connection to the database (at least to check that it exists) and then close it. There's no point in keeping a connection open unnecessarily. Don't worry about performance. Opening a database is very quick as the DB server will usually cache connections and simply give you one it 'prepared earlier'.

Open the IP ports you wish to listen to and figure out how you will wait for something to arrive. The CodeProject ( has a pretty good (free) library assembly called UNOLibs.Net that will do the job. You must use the WithEvents clause when DIMing the IP port objects. There's a pretty good tutorial that comes with it

Assign a different Sub to the IncomingMessage event of each IP Port object and in each of these open the connection, update the appropriate table using the contents of the message and close the connection.

You'll need to provide a means of killing the application. I suggest a special message sent to one (or any) of the ports that is interpreted as a kill signal.

If you weren't working with VB.NET Express I'd also recommend turning the entire application into a Service program but you can't do that with VB.NET Express easily





Bob Boffin
 
Opening a database is very quick as the DB server will usually cache connections and simply give you one it 'prepared earlier'.

Uhm, nope.

The first connection always takes longest because the connection pooling is done locally. Try writing some unit tests you will notice the time it takes to make the first coonection. After that ado.net keeps one open to make the following connections faster. You can close them all if needed. And then the next one will open slower again. The database should close idle connections after a while.

Christiaan Baes
Belgium

"My old site" - Me
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top