How to create database using vbscript code?
Please tell me how to create database in sql server using vbscript code? And where we have to write the code?
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Nilanka DharmadasaRank #1,875 · 794 reputationPosted Nov 6, 2009, 9:41 PM EST
You can write this in your script to connect to your SQL server DB.
Const adOpenStatic = 3
Const adLockOptimistic = 3
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")
objConnection.Open _
objConn.Open "Driver={SQL Server};" & _
"Server=YourServer\DatabaseInstance;" & _
"Database=DatabaseName;" & _
"user id=username;" & _
"password=password;"
objRecordSet.Open "SELECT * FROM Customers", _
objConnection, adOpenStatic, adLockOptimistic
objRecordSet.MoveFirst
If this helps you please accept my answer...