Movian
05-20-2011, 03:01 PM
Hey,
i am trying to implement a new feature to our auto update system. when a new version of our front end system is downloaded it checks to see if there is a table update script. If found it currently uses winhttp to request the file which is a .sql from our server and store the returned text in a string (its rather large though at 711704 chars and 24456 lines.
My thinking was that i could then just run this SQL command using the following code. However this does not seem to work, while if i execute the contents in management studio it executes correctly.
Here is a sample of the some of the contents of the SQL file and the code I'm using to execute. If anyone has any suggestions, I'm thinking i could download the whole file save it as a .sql file then run it from that somehow.... any thoughts?
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Accreditation]') AND type in (N'U'))
BEGIN
CREATE TABLE [Accreditation]([ID] int, [PatientID] nvarchar(255), [DateOfService] datetime, [Study] nvarchar(255), [CaseStudy] bit, [Re-Scan] bit, [Re-Read] bit, [Correlation] bit, [Tech] nvarchar(100), [Physician] nvarchar(100), [Tech+] bit, [Phys+] bit, [upsize_ts] timestamp, )
END
ELSE
BEGIN
IF col_length('Accreditation','ID') is null
BEGIN
ALTER TABLE [Accreditation] ADD [ID] int
END
IF col_length('Accreditation','PatientID') is null
BEGIN
ALTER TABLE [Accreditation] ADD [PatientID] nvarchar(255)
END
IF col_length('Accreditation','DateOfService') is null
BEGIN
ALTER TABLE [Accreditation] ADD [DateOfService] datetime
END
DoCmd.RunSQL
mycon.Open "GET", VarStoring.SQLlocation
mycon.Send
mycon.waitforresponse
TableUpdate = mycon.responsetext
On Error Resume Next
DoCmd.RunSQL TableUpdate
On Error GoTo 0
i am trying to implement a new feature to our auto update system. when a new version of our front end system is downloaded it checks to see if there is a table update script. If found it currently uses winhttp to request the file which is a .sql from our server and store the returned text in a string (its rather large though at 711704 chars and 24456 lines.
My thinking was that i could then just run this SQL command using the following code. However this does not seem to work, while if i execute the contents in management studio it executes correctly.
Here is a sample of the some of the contents of the SQL file and the code I'm using to execute. If anyone has any suggestions, I'm thinking i could download the whole file save it as a .sql file then run it from that somehow.... any thoughts?
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Accreditation]') AND type in (N'U'))
BEGIN
CREATE TABLE [Accreditation]([ID] int, [PatientID] nvarchar(255), [DateOfService] datetime, [Study] nvarchar(255), [CaseStudy] bit, [Re-Scan] bit, [Re-Read] bit, [Correlation] bit, [Tech] nvarchar(100), [Physician] nvarchar(100), [Tech+] bit, [Phys+] bit, [upsize_ts] timestamp, )
END
ELSE
BEGIN
IF col_length('Accreditation','ID') is null
BEGIN
ALTER TABLE [Accreditation] ADD [ID] int
END
IF col_length('Accreditation','PatientID') is null
BEGIN
ALTER TABLE [Accreditation] ADD [PatientID] nvarchar(255)
END
IF col_length('Accreditation','DateOfService') is null
BEGIN
ALTER TABLE [Accreditation] ADD [DateOfService] datetime
END
DoCmd.RunSQL
mycon.Open "GET", VarStoring.SQLlocation
mycon.Send
mycon.waitforresponse
TableUpdate = mycon.responsetext
On Error Resume Next
DoCmd.RunSQL TableUpdate
On Error GoTo 0