Re: Running sql-query

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



On Tue, 14 Jun 2005 14:19:09 +0200, "ReidarT" <reidar@xxxxxxxx> wrote:

>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


.



Relevant Pages

  • RE: Breaking down imported information
    ... Single-record append query: ... ' Check if at EOF of Recordset (rsDataViaCode) ... ' if at EOF Exit Do. ... Dim rsDataViaCode As DAO.Recordset ...
    (microsoft.public.access.modulesdaovba)
  • Re: Could a change of SQL ports break a data reader?
    ... Can you use SQL Profiler ... to catch the statement that gets executed, paste it into query ... > Dim connectionString As String ... > ' now we have a valid connection string ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: LDAP query information
    ... Copyright 1985-2001 Microsoft Corp. ... Dim strBase, strFilter, strAttributes, strQuery, adoRecordset ... Set adoConnection = CreateObject ... ' Construct LDAP syntax query. ...
    (microsoft.public.windows.server.scripting)
  • Re: LDAP query information
    ... Dim strBase, strFilter, strAttributes, strQuery, adoRecordset ... Set adoConnection = CreateObject ... ' Construct LDAP syntax query. ... Yes, the script uses ADO to query AD directly, which is very efficient - no ...
    (microsoft.public.windows.server.scripting)
  • Re: Need WMI script
    ... I also assume that strGroupName is ... If instead strDomainName is the NetBIOS name of a domain, ... Dim adoCommand, adoConnection, strBase, strFilter, strAttributes, xmlDoc, ... ' Construct the LDAP syntax query. ...
    (microsoft.public.windows.server.scripting)