Results 1 to 2 of 2

Thread: Long SQL statements

Threaded View

  1. #1

    Thread Starter
    Fanatic Member x-ice's Avatar
    Join Date
    Mar 2004
    Location
    UK
    Posts
    671

    Resolved Long SQL statements

    VB Code:
    1. Private Sub SetSQLStatements()
    2.         'Add parameters to use in SQL statements
    3.         With cmdStaff.Parameters
    4.             .Add("@EmpID", txtEmpID.Text)
    5.             .Add("@Surname", txtSurname.Text)
    6.             .Add("@Forename", txtForename.Text)
    7.             .Add("@Gender", txtGender.Text)
    8.             .Add("@DOB", dtpDOB.Text)
    9.             .Add("@Address", txtAddress.Text)
    10.             .Add("@Postcode", txtPostcode.Text)
    11.             .Add("@TelNum", txtTelNum.Text)
    12.             .Add("@Contract", txtContract.Text)
    13.             .Add("@Salary", txtSalary.Text)
    14.             .Add("@Position", txtPosition.Text)
    15.             .Add("@StartDate", dtpStartDate.Text)
    16.             .Add("@BookRight", cboBookingRights.Text)
    17.             .Add("@LoginRight", cboLoginRights.Text)
    18.             .Add("@MemberRight", cboMemberRights.Text)
    19.             .Add("@ManageRight", cboManageRights.Text)
    20.         End With
    21.         'Set SQL statements
    22.         With daStaff
    23.             .DeleteCommand.CommandText = "DELETE FROM Staff" 'Delete statement
    24.             .InsertCommand.CommandText = "INSERT INTO Staff" 'Insert statement
    25.             .[B]UpdateCommand.CommandText = "UPDATE Staff SET Address = @Address, BookingRights = @BookRight, Contract = @Contract, DOB = @DOB, Forename = @Forename, Gender = @Gender, LoginRights = @LoginRight, ManageRights = @ManageRight, MemberRights = @MemberRight, Position = @Position, Postcode = @Postcode, Salary = @Salary, StartDate = @StartDate, Surname = @Surname, [Telephone Number] = @TelNum" 'Update statement[/B]
    26.         End With
    27.     End Sub
    What can i do make the SQL statement in bold stretch over more lines of code, so that the whole statement can be seen without scrolling the code window?

    When i try to do this like i would with an ordinary string i get a syntax error.

    p.s. I take a string to a new line by doing.
    VB Code:
    1. Dim bla as String
    2. bla = "bla......................................................................." & _
    3. "hello"
    This doesn't appear to work with SQL statements though.
    Last edited by x-ice; Jun 4th, 2005 at 06:31 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width