Zum Hauptinhalt gehen

Suche

Suche

Updating An External Db (Not Set Up Under Db Connections)

Kommentare

3 Kommentare

  • Avatar
    Legacy Poster

    UPDATE:

     

    I moved the update code from the single line text object to the BarTender Document Options (View > View Options > VB Scripting > OnPrintJobEnd). I have also added a variable to determine if printing was cancelled or processed and increase it only when a job has completed successfully. This seems to have trapped the issue.

    0
  • Avatar
    Legacy Poster

    I need to do something similar -- except that I'll be updating a SQL Server database so I'll need to change the connection information.  How do I set that up?

     

    Thanks,

    Valerie

    0
  • Avatar
    Domingo Rodriguez
    Moderator
    Although I've never tried to connect to an SQL Server database using VBScript, find below some code on how to achieve this:

    <%
    'declare the variables
    Dim Connection
    Dim ConnString
    Dim Recordset
    Dim SQL

    'define the connection string, specify database driver
    ConnString="DRIVER={SQL Server};SERVER=yourServername;UID=yourUsername;" & _
    "PWD=yourPassword;DATABASE=yourDatabasename"

    'declare the SQL statement that will query the database
    SQL = "SELECT * FROM TABLE_NAME"

    'create an instance of the ADO connection and recordset objects
    Set Connection = Server.CreateObject("ADODB.Connection")
    Set Recordset = Server.CreateObject("ADODB.Recordset")

    'Open the connection to the database
    Connection.Open ConnString

    'Open the recordset object executing the SQL statement and return records
    Recordset.Open SQL,Connection

    'first of all determine whether there are any records
    If Recordset.EOF Then
    Response.Write("No records returned.")
    Else
    'if there are records then loop through the fields
    Do While NOT Recordset.Eof
    Response.write Recordset("FIRST_FIELD_NAME")
    Response.write Recordset("SECOND_FIELD_NAME")
    Response.write Recordset("THIRD_FIELD_NAME")
    Response.write "<br>"
    Recordset.MoveNext
    Loop
    End If

    'close the connection and recordset objects to free up resources
    Recordset.Close
    Set Recordset=nothing
    Connection.Close
    Set Connection=nothing
    %>
    0

Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.