Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how to execute 2 sql command in one connection in vb.net
Posted

1 solution

Simple: either create two separate SqlCommand objects and connect them to the same SqlCommand object (provided you don't use SqlDataReaders it'll be fine) or send them both as a single SqlCommand but separating the two commands with a semicolon:
VB
Dim cmd As SqlCommand = New SqlCommand("INSERT INTO MyTable (MyColumn) VALUES ('Hello'); SELECT * FROM MyTable", con)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900