A desperate plea for help....

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

Currently, I am a spring chicken in VB and I am writing a program concerning
vb.net 2003 and SQL Server 2005. This program is basically a data collection
app in which collects data from a wedge scanner via barcodes. I have two
questions concerning this program.

1. I have created the sql connection, data adapter, and data set as objects
within the form design and the data adapter automatically created my INSERT,
UPDATE, and DELETE commands with the text strings. You probably already know
what I am going to ask, but here goes...I need to access these commands
within the code of the app, but I am confused on how to access them. I have
gone through alot of info on this, but mostly I see that the connection,
adapter, and dataset, etc. are invoked through the code. Do I need to do this
even though these are already created through objects on the form? How do I
access these objects through the code?
Here are the names of the objects as displayed in the form designer:

Data adapter:db_Adapter1
db_Adapter2
(I have two, one for my tbl_HDR table and one for my tbl_DET table. The HDR
table contains a relationship with a field called ProcessID with the DET
Table and I have them set in SQL Server as AutoIncrement)


SQL Connector: db_Conn

Dataset: db_RS

I have tried to use an INSERT INTO command, but vb complains and says it's
not declared. I have a deadline on this and any and all help will be
appreciated. I need to use these commands to add, update, and delete records
when the info is scanned in. As I said before, all of the info I am getting
is only confusing me more...hopefully someone else had been in the same
position as I and can clear this up for me once and for all

2. If I try to use validation tactics for the scanner on the first textbox
control, the first letter appears in the field, I hear a beep, and the rest
of the text goes into the other fields. If I do not use any input validation,
it works fine...could this be due to using the default 'text_changed' method
on the field? Or could this be due to a character that the scanner is putting
in after scanning the bar code?

This seems like a great group to help others...TIA
 
I'm not at all certain why you need (or think you need) access to the
generated Commands but these are available at runtime through the
DataAdapter. For example, the INSERT command is found at
myDataAdapter.InsertCommand.CommandText

What text does the scanner extrude (exactly)?

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
-----------------------------------------------------------------------------------------------------------------------
 
Hi Bill,

Thanks for the reply. I guess I need to be more clear as to what I am asking
for. I am seeing repeated use of INSERT INTO mytable(mycolumn)
Values(@myvalue) everywhere!...question is, how the heck do you get to
this?Is there any prereq code I am missing here?...I have noticed that this
is actually the insert command text in my data adapter as well. If you just
put this code in, VB says that "INSERT" is not declared...I am getting so
frustrated...thanks again...
 
How do you know the "Insert", "Update" and "Delete" commands are
created? You did not mention about "SqlCommandBuilder".

To create the commands, you need to use "SqlCommandBuilder" class.

dim cmb as new SqlCommandBuilder(sqlAdapter);

You can get the commands generated by SqlCommandBuilder using
GetDeleteCommand, GetInsertCommand and GetUpdateCommand.

In most cases, you should avoid using SqlCommandBuilder class or any
other classes derives from DbCommandBuilder, since the commands
generated are NOT efficient for real life applications.

Charles Zhang
SpeedyDB Technologies ( SpeedyDB ADO.NET Provider )
http://www.speedydb.com
 
How do you know the "Insert", "Update" and "Delete" commands are
created? You did not mention about "SqlCommandBuilder".

To create the commands, you need to use "SqlCommandBuilder" class.

dim cmb as new SqlCommandBuilder(sqlAdapter);

You can get the commands generated by SqlCommandBuilder using
GetDeleteCommand, GetInsertCommand and GetUpdateCommand.

In most cases, you should avoid using SqlCommandBuilder class or any
other classes derives from DbCommandBuilder, since the commands
generated are NOT efficient for real life applications.

Charles Zhang
SpeedyDB Technologies ( SpeedyDB ADO.NET Provider )
http://www.speedydb.com
 
Back
Top