INSERT into sql server table

User avatar
sal21
PlatinumLounger
Posts: 4335
Joined: 26 Apr 2010, 17:36

INSERT into sql server table

Post by sal21 »

Code: Select all

...
  Set CNN = New ADODB.Connection

    strCnString = "Provider=SQLOLEDB;" & _
                  "Data Source=DESKTOP-TQPVR2M\SQLEXPRESS;" & _
                  "Initial Catalog=CPO;Integrated Security=SSPI;"
    CNN.Open strCnString
    ...
how to insert value into the fields of table1 of CPO database via sql insert?

User avatar
HansV
Administrator
Posts: 78350
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: INSERT into sql server table

Post by HansV »

Code: Select all

    Dim SQL As String
    SQL = "INSERT INTO TABLE Table1 (Field1, Field2, Field3) VALUES ('Sal21', 'Napoli', 123456)"
    CNN.Execute CommandText:=SQL, Optiobs:=adExecuteNoRecords
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4335
Joined: 26 Apr 2010, 17:36

Re: INSERT into sql server table

Post by sal21 »

HansV wrote:
17 Jun 2022, 15:20

Code: Select all

    Dim SQL As String
    SQL = "INSERT INTO TABLE Table1 (Field1, Field2, Field3) VALUES ('Sal21', 'Napoli', 123456)"
    CNN.Execute CommandText:=SQL, Optiobs:=adExecuteNoRecords
ohhhhh....
similar access database....
i'm stupid

User avatar
sal21
PlatinumLounger
Posts: 4335
Joined: 26 Apr 2010, 17:36

Re: INSERT into sql server table

Post by sal21 »

HansV wrote:
17 Jun 2022, 15:20

Code: Select all

    Dim SQL As String
    SQL = "INSERT INTO TABLE Table1 (Field1, Field2, Field3) VALUES ('Sal21', 'Napoli', 123456)"
    CNN.Execute CommandText:=SQL, Optiobs:=adExecuteNoRecords
Hi bro, (no good exerience with SqlServer and ado) how to integrate ID and PASSWORD, if the server have?
If is possible with my conn string in post.
Tks

Note:
Please use ID and PASSWORD in a dim string

ID="sal21"
PASSWORD ="123456"

for example

User avatar
HansV
Administrator
Posts: 78350
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: INSERT into sql server table

Post by HansV »

Code: Select all

    strCnString = "Provider=SQLOLEDB;" & _
                  "Data Source=DESKTOP-TQPVR2M\SQLEXPRESS;" & _
                  "Initial Catalog=CPO;Integrated Security=SSPI;User Id=sal21;Password=123456;"
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4335
Joined: 26 Apr 2010, 17:36

Re: INSERT into sql server table

Post by sal21 »

HansV wrote:
17 Jun 2022, 18:42

Code: Select all

    strCnString = "Provider=SQLOLEDB;" & _
                  "Data Source=DESKTOP-TQPVR2M\SQLEXPRESS;" & _
                  "Initial Catalog=CPO;Integrated Security=SSPI;User Id=sal21;Password=123456;"
:cheers: :clapping: