Running sql-query

  • Thread starter Thread starter ReidarT
  • Start date Start date
R

ReidarT

How do I run this query
Dim objConnectionUNI As OleDbConnection = New OleDbConnection(connUNI)
Dim objDataAdapter As OleDbDataAdapter = New OleDbDataAdapter( _
"INSERT INTO tblDebitor ( Kontonr, KontoNrTall, Kontnavn,
Adresse, Postnr, Poststed, " & _
"Land, Saliår, Salifjor ) " & _
"SELECT DEBITOR.Kontonr, DEBITOR.Kontonr, DEBITOR.Kontnavn,
DEBITOR.Adresse, DEBITOR.Postnr, " & _
"DEBITOR.Poststed, DEBITOR.Land, DEBITOR.Saliår,
DEBITOR.Salifjor " & _
"FROM DEBITOR " & _
"WHERE tblDebitor.Kontonr Not = DEBITOR.Kontonr", objConnection)

How do I run this query?

regards
reidarT
 
How do I run this query
Dim objConnectionUNI As OleDbConnection = New OleDbConnection(connUNI)
Dim objDataAdapter As OleDbDataAdapter = New OleDbDataAdapter( _
"INSERT INTO tblDebitor ( Kontonr, KontoNrTall, Kontnavn,
Adresse, Postnr, Poststed, " & _
"Land, Saliår, Salifjor ) " & _
"SELECT DEBITOR.Kontonr, DEBITOR.Kontonr, DEBITOR.Kontnavn,
DEBITOR.Adresse, DEBITOR.Postnr, " & _
"DEBITOR.Poststed, DEBITOR.Land, DEBITOR.Saliår,
DEBITOR.Salifjor " & _
"FROM DEBITOR " & _
"WHERE tblDebitor.Kontonr Not = DEBITOR.Kontonr", objConnection)

How do I run this query?

The way I would run it:

dim cn as sqlconnection
dim cmd as sqlcommand
dim sSQL as string

sSQL = "INSERT INTO tblDebitor ( Kontonr, KontoNrTall, Kontnavn," &_
"Adresse, Postnr, Poststed, " & _
"Land, Saliår, Salifjor ) " & _
"SELECT DEBITOR.Kontonr, DEBITOR.Kontonr, EBITOR.Kontnavn,
DEBITOR.Adresse, DEBITOR.Postnr, " & _
"DEBITOR.Poststed, DEBITOR.Land, DEBITOR.Saliår,
DEBITOR.Salifjor " & _
"FROM DEBITOR " & _
"WHERE tblDebitor.Kontonr Not = DEBITOR.Kontonr"
cn = new sqlconnection("appropriate connection string")
cmd = new sqlcommand(sSQL, cn)
cmd.executenonquery()
cmd.dispose
cn.close
cn.dispose
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top