{"id":188,"date":"2007-08-23T13:00:00","date_gmt":"2007-08-23T21:00:00","guid":{"rendered":"http:\/\/testblog.sapien.com\/index.php\/2007\/08\/23\/new-in-primalscript-2007-ado-database-wizard\/"},"modified":"2007-08-23T13:00:00","modified_gmt":"2007-08-23T21:00:00","slug":"new-in-primalscript-2007-ado-database-wizard","status":"publish","type":"post","link":"https:\/\/dev.sapien.com\/blog\/2007\/08\/23\/new-in-primalscript-2007-ado-database-wizard\/","title":{"rendered":"New in PrimalScript 2007: ADO Database Wizard"},"content":{"rendered":"<p>A common task for scripters is working with databases. Typically VBScript coders use ADO to access database tables. However, creating code to access, modify or otherwise interact with databases can be arcane and mystifying. The Professional and Enterprise editions of PrimalScript 2007 include an ADO Wizard that generates VBScript code.<\/p>\n<p><img decoding=\"async\" style=\"width: 334px; height: 270px\" alt=\"adowizard-generatecode.png\" src=\"\/storage\/primalscript2007\/adowizard-generatecode.png\" \/><\/p>\n<p>Using a database connection from the Database Browser, right-click the table you want to work with and select Generate VBScript Code.<\/p>\n<p><span class=\"full-image-float-none\"><img decoding=\"async\" style=\"width: 433px; height: 209px\" alt=\"adowizard-settings.png\" src=\"\/storage\/primalscript2007\/adowizard-settings.png\" \/><\/span><\/p>\n<p>The Wizard automatically generates the connection string. You can adjust the settings to control what type of code is generated.<\/p>\n<p>Here&#8217;s my wizard generated code that only took me a few mouse clicks:<\/p>\n<p><font face=\"Courier New\"><font style=\"color: #0000ff\" color=\"#0000ff\">On Error Resume Next<\/font><br \/><font style=\"color: #008000\" color=\"#008000\">&#8216;Database connection<\/font><br \/><font style=\"color: #0000ff\" color=\"#0000ff\">Dim<\/font> objCn<br \/><font style=\"color: #0000ff\" color=\"#0000ff\">Set<\/font> objCn = <font style=\"color: #0000ff\" color=\"#0000ff\">CreateObject<\/font>(<font style=\"color: #800000\" color=\"#800000\">&#8220;ADODB.Connection&#8221;<\/font>)<br \/>objCn.Open <font style=\"color: #800000\" color=\"#800000\">&#8220;Provider=SQLOLEDB.1;Integrated Security=SSPI;&#8221; &amp;_<br \/>&#8221;<\/font><\/font><font face=\"Courier New\"><font style=\"color: #800000\" color=\"#800000\">Persist Security Info=False;Initial Catalog=JDHDB;&#8221; &amp;_<br \/>&#8220;Data Source=godot\\sqlexpress&#8221;<\/font> <\/font><\/p>\n<p><font face=\"Courier New\"><font style=\"color: #008000\" color=\"#008000\">&#8216;Query data<\/font><br \/><font style=\"color: #0000ff\" color=\"#0000ff\">Const<\/font> ADO_Dynamic = 2<br \/><font style=\"color: #0000ff\" color=\"#0000ff\">Const<\/font> ADO_FwdOnly = 0<br \/><font style=\"color: #0000ff\" color=\"#0000ff\">Const<\/font> ADO_Keyset = 1<br \/><font style=\"color: #0000ff\" color=\"#0000ff\">Const<\/font> ADO_Static = 3 <\/font><\/p>\n<p><font face=\"Courier New\"><font style=\"color: #0000ff\" color=\"#0000ff\">Dim<\/font> rs_Computers, strSQL<br \/>strSQL = <font style=\"color: #800000\" color=\"#800000\">&#8220;Select * from Computers&#8221;<\/font> <\/font><\/p>\n<p><font face=\"Courier New\"><font style=\"color: #0000ff\" color=\"#0000ff\">Set<\/font> rs_Computers = <font style=\"color: #0000ff\" color=\"#0000ff\">CreateObject<\/font>(<font style=\"color: #800000\" color=\"#800000\">&#8220;ADODB.RecordSet&#8221;<\/font>)<br \/>rs_Computers.Open strSQL, objCn, ADO_FwdOnly <\/font><\/p>\n<p><font face=\"Courier New\"><font style=\"color: #008000\" color=\"#008000\">&#8216;Go through data<br \/><\/font><font style=\"color: #0000ff\" color=\"#0000ff\">Do Until<\/font> rs_Computers.EOF<br \/>&nbsp;&nbsp;&nbsp; WScript.Echo rs_Computers(<font style=\"color: #800000\" color=\"#800000\">&#8220;Name&#8221;<\/font>)<br \/>&nbsp;&nbsp;&nbsp; WScript.Echo rs_Computers(<font style=\"color: #800000\" color=\"#800000\">&#8220;AssetTag&#8221;<\/font>)<br \/>&nbsp;&nbsp;&nbsp; WScript.Echo rs_Computers(<font style=\"color: #800000\" color=\"#800000\">&#8220;Updated&#8221;<\/font>)<br \/>&nbsp;&nbsp;&nbsp; rs_Computers.MoveNext<br \/><font style=\"color: #0000ff\" color=\"#0000ff\">Loop<\/font><br \/><font style=\"color: #008000\" color=\"#008000\">&#8216;Close database connections<\/font><br \/>rs_Computers.Close<br \/>objCn.Close<br \/><font style=\"color: #0000ff\" color=\"#0000ff\">On Error GoTo 0<\/font><\/font><font style=\"color: #0000ff\" color=\"#0000ff\"> <\/font><\/p>\n<p>I can insert this into my open VBScript, and I&#8217;m done! Now you can create database scripts in fraction of the time. The wizard will also let you create custom class objects to make it easier to update or insert new data. It will even generate some sample code to give you a guideline on how to use the classes.<\/p>\n<p>You can try out the ADO wizard and other new features by downloading a 45 day evaluation copy of <a href=\"http:\/\/www.primalscript.com\/default.asp\" target=\"_blank\">PrimalScript 2007<\/a>.<\/p>\n<div class=\"wlWriterSmartContent\" id=\"0767317B-992E-4b12-91E0-4F059A8CECA8:e073016b-8114-4280-b85a-ff2aac0cdcd4\" style=\"padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px\">Technorati Tags: <a href=\"http:\/\/technorati.com\/tags\/SAPIEN\" rel=\"tag\">SAPIEN<\/a>, <a href=\"http:\/\/technorati.com\/tags\/PrimalScript\" rel=\"tag\">PrimalScript<\/a>, <a href=\"http:\/\/technorati.com\/tags\/ADO\" rel=\"tag\">ADO<\/a>, <a href=\"http:\/\/technorati.com\/tags\/ADODB\" rel=\"tag\">ADODB<\/a>, <a href=\"http:\/\/technorati.com\/tags\/Database\" rel=\"tag\">Database<\/a>, <a href=\"http:\/\/technorati.com\/tags\/VBScript\" rel=\"tag\">VBScript<\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>A common task for scripters is working with databases. Typically VBScript coders use ADO to access database tables. However, creating code to access, modify or otherwise interact with databases can be arcane and mystifying. The Professional and Enterprise editions of PrimalScript 2007 include an ADO Wizard that generates VBScript code which you can insert directly into an open VBScript.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[21],"tags":[],"class_list":["post-188","post","type-post","status-publish","format-standard","hentry","category-software-news"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/188","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/comments?post=188"}],"version-history":[{"count":0,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/188\/revisions"}],"wp:attachment":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/media?parent=188"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/categories?post=188"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/tags?post=188"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}