Here is a sample VB Script code that demonstrates how to insert data into an MS SQL database using ADODB connection:
vbnetCopy code
Dim conn
Set conn = CreateObject("ADODB.Connection")
' Set the connection string for your SQL Server database
conn.ConnectionString = "Provider=SQLOLEDB;Data Source=yourServerName;Initial Catalog=yourDatabaseName;User ID=yourUsername;Password=yourPassword;"' Open the database connection
conn.Open
' Create an SQL INSERT statementDim sqlInsert
sqlInsert = "INSERT INTO yourTableName (column1, column2, column3) VALUES ('value1', 'value2', 'value3')"' Execute the INSERT statement
conn.Execute sqlInsert
' Close the database connection
conn.Close
' Clean up the connection objectSet conn = Nothing
In the code above, you need to replace the values for "yourServerName", "yourDatabaseName", "yourUsername", "yourPassword", "yourTableName", "column1", "column2", and "column3" with your own values that match your database setup.
You can add more columns and values to the INSERT statement as needed, and use variables to dynamically insert data from your VBScript code.
Note that this code assumes that you have already installed the SQL Server OLE DB Provider and have the necessary permissions to access and modify the database.
Happy Support