Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Help with syntax

Help with syntax

Scheduled Pinned Locked Moved Visual Basic
questionsecurityhelpannouncement
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MUSIWA
    wrote on last edited by
    #1

    Dim sqlConnection1 As New System.Data.SqlClient.SqlConnection("Data Source=MUSCRIBMPC\SQLEXPRESS;Initial Catalog=adp3SQL;Integrated Security=True") Dim fname, lname As String fname = TextBox2.Text lname = textbox2.text Dim cmd As New System.Data.SqlClient.SqlCommand cmd.CommandType = System.Data.CommandType.Text cmd.CommandText = "update compiledpts set firstname=fname, lastname=lname where contactid = 2" cmd.Connection = sqlConnection1 sqlConnection1.Open() cmd.ExecuteNonQuery() sqlConnection1.Close() contactid is the table ID, compiledpts is the name of the table. everything else works except the syntax in the commandtext. if firstname is = " anytext " it updates with that text but I cannot use fname and I cannot use more than one viriable. WHAT IS WRONG PLEASE?

    T 1 Reply Last reply
    0
    • M MUSIWA

      Dim sqlConnection1 As New System.Data.SqlClient.SqlConnection("Data Source=MUSCRIBMPC\SQLEXPRESS;Initial Catalog=adp3SQL;Integrated Security=True") Dim fname, lname As String fname = TextBox2.Text lname = textbox2.text Dim cmd As New System.Data.SqlClient.SqlCommand cmd.CommandType = System.Data.CommandType.Text cmd.CommandText = "update compiledpts set firstname=fname, lastname=lname where contactid = 2" cmd.Connection = sqlConnection1 sqlConnection1.Open() cmd.ExecuteNonQuery() sqlConnection1.Close() contactid is the table ID, compiledpts is the name of the table. everything else works except the syntax in the commandtext. if firstname is = " anytext " it updates with that text but I cannot use fname and I cannot use more than one viriable. WHAT IS WRONG PLEASE?

      T Offline
      T Offline
      Tirthadip
      wrote on last edited by
      #2

      The syntax would be.... "update compiledpts set firstname='" & fname & "', lastname='" & lname & "' where contactid = 2"

      Tirtha Do not go where the path may lead, go instead where there is no path and leave a trail. Author: Ralph Waldo Emerson (1803-82), American writer, philosopher, poet, essayist

      M 1 Reply Last reply
      0
      • T Tirthadip

        The syntax would be.... "update compiledpts set firstname='" & fname & "', lastname='" & lname & "' where contactid = 2"

        Tirtha Do not go where the path may lead, go instead where there is no path and leave a trail. Author: Ralph Waldo Emerson (1803-82), American writer, philosopher, poet, essayist

        M Offline
        M Offline
        MUSIWA
        wrote on last edited by
        #3

        Thankyou so very much I can not thankyou enough. It worked perfectely. Infact I am now trying to expand the same to allow insert and delete. You have helped me immensely. Thankyou you are a very good person :-D

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups