quick question

  • Thread starter Thread starter rbutch
  • Start date Start date
R

rbutch

when creating an instance of a Command object
can you do mulitple inserts?
or would i have to keep creating a new instance each time i wanted a new row?
if you can do multiples, how would i instantiate that same obj each time?

Dim cmd As New OleDbCommand("Insert into TimeCard2(Empl_id,balance_date,Reg_Hours)VALUES('E1234','3/05/2005','8'")",New OleDbConnection(strConnection))

Dim cmd2 As New OleDbCommand("Insert into TimeCard2(Empl_id,balance_date)VALUES('E4567','3/06/2005','12'")",New OleDbConnection(strConnection))


thanks as usual
rik

**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
 
Hi Rik,

You can use a command object to perform multi-sql commands

Following code shows how to do it:

Dim connection As New OleDbConnection(CONNECT_STRING)
Dim command As OleDbCommand = connection.CreateCommand()
command.CommandType = CommandType.Text
connection.Open()

command.CommandText = "INSERT INTO TABLE_NAME VALUES(.."
Command. ExecuteNonQuery()

command.CommandText = "INSERT INTO TABLE_NAME VALUES(.."
Command. ExecuteNonQuery()

command.CommandText = "UPDATE TABLE_NAME SET ."
command. ExecuteNonQuery()

command.CommandText = "SELECT * FROM TABLE_NAME ."
Dim dataReader As OleDbDataReader = command.ExecuteReader()
..

connection.Close()

HTH

Elton Wang
(e-mail address removed)
-----Original Message-----
when creating an instance of a Command object
can you do mulitple inserts?
or would i have to keep creating a new instance each time i wanted a new row?
if you can do multiples, how would i instantiate that same obj each time?

Dim cmd As New OleDbCommand("Insert into TimeCard2
(Empl_id,balance_date,Reg_Hours)VALUES
('E1234','3/05/2005','8'")",New OleDbConnection
(strConnection))
Dim cmd2 As New OleDbCommand("Insert into TimeCard2
(Empl_id,balance_date)VALUES
('E4567','3/06/2005','12'")",New OleDbConnection
(strConnection))
thanks as usual
rik

********************************************************** ************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of
links to ASP & ASP.NET resources...
 
absolutely excellent.
thank you so much.
rik

**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
 
Back
Top