Running sql-query

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ReidarT

    #1

    Running sql-query

    How do I run this query
    Dim objConnectionUN I As OleDbConnection = New OleDbConnection (connUNI)
    Dim objDataAdapter As OleDbDataAdapte r = New OleDbDataAdapte r( _
    "INSERT INTO tblDebitor ( Kontonr, KontoNrTall, Kontnavn,
    Adresse, Postnr, Poststed, " & _
    "Land, Saliår, Salifjor ) " & _
    "SELECT DEBITOR.Kontonr , DEBITOR.Kontonr , DEBITOR.Kontnav n,
    DEBITOR.Adresse , DEBITOR.Postnr, " & _
    "DEBITOR.Postst ed, DEBITOR.Land, DEBITOR.Saliår,
    DEBITOR.Salifjo r " & _
    "FROM DEBITOR " & _
    "WHERE tblDebitor.Kont onr Not = DEBITOR.Kontonr ", objConnection)

    How do I run this query?

    regards
    reidarT


  • Joe Cool

    #2
    Re: Running sql-query

    On Tue, 14 Jun 2005 14:19:09 +0200, "ReidarT" <reidar@eivon.n o> wrote:
    [color=blue]
    >How do I run this query
    >Dim objConnectionUN I As OleDbConnection = New OleDbConnection (connUNI)
    > Dim objDataAdapter As OleDbDataAdapte r = New OleDbDataAdapte r( _
    > "INSERT INTO tblDebitor ( Kontonr, KontoNrTall, Kontnavn,
    >Adresse, Postnr, Poststed, " & _
    > "Land, Saliår, Salifjor ) " & _
    > "SELECT DEBITOR.Kontonr , DEBITOR.Kontonr , DEBITOR.Kontnav n,
    >DEBITOR.Adress e, DEBITOR.Postnr, " & _
    > "DEBITOR.Postst ed, DEBITOR.Land, DEBITOR.Saliår,
    >DEBITOR.Salifj or " & _
    > "FROM DEBITOR " & _
    > "WHERE tblDebitor.Kont onr Not = DEBITOR.Kontonr ", objConnection)
    >
    >How do I run this query?[/color]

    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.Postst ed, DEBITOR.Land, DEBITOR.Saliår,
    DEBITOR.Salifjo r " & _
    "FROM DEBITOR " & _
    "WHERE tblDebitor.Kont onr Not = DEBITOR.Kontonr "
    cn = new sqlconnection(" appropriate connection string")
    cmd = new sqlcommand(sSQL , cn)
    cmd.executenonq uery()
    cmd.dispose
    cn.close
    cn.dispose


    Comment

    Working...