سؤال

My company has a client that registers users for events by sending us an excel spreadsheet containing four fields - name, email, phone, and role. I have written a VB script that converts the file into CSV, then parses that CSV. On each line, I check to see if more than four elements are returned (Sometimes names include a title or something) and then I do a replace in a variable called SQL. SQL is the instance variable for SQL_MASK, which contains all of the queries needed to set variables, etc. and add a new or update the existing record as needed.

Everything works beautifully, except when it comes to the actual database code. I studied some existing code from the people before me, and this fits the syntax I saw them using.

Unfortunately, I can't get VB to stop throwing errors like this:

(15, 5) Microsoft VBScript runtime error: Object required: ''

Here is the relevant part of my code...

12 dim dbconn, connect
13 connect = "Driver={SQL Server};Server=XXX;Database=XXX;uid=XXX;pwd=XXX"
14 dbconn = CreateObject("ADODB.Connection")
15 dbconn.Open connect
16 dbconn.Execute(SQL)

I couldn't really find documentation that I could make heads or tails of (I am hardware/user support through experience/training, programmer only through trial by fire).

Can someone tell me what I'm missing? I would appreciate any help!

هل كانت مفيدة؟

المحلول

You are missing a set command on line 14 maybe that's it? The driver will depend on what type of machine you are running the script on.

dim dbconn, connect
connect = "Driver={SQL Server};Server=XXX;database=XXX;uid=XXX;pwd=XXX"
Set dbconn = CreateObject("ADODB.Connection")
dbconn.Open connect
dbconn.Execute(SQL)
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top