Update Syntax Problem

  • (2 Pages)
  • +
  • 1
  • 2

22 Replies - 1611 Views - Last Post: 04 September 2010 - 08:52 PM Rate Topic: -----

#16 mpe-IT  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 152
  • Joined: 27-November 09

Re: Update Syntax Problem

Posted 04 September 2010 - 04:21 AM

it is now working! THANK YOU so much pal! :bigsmile:

btw can you pls explain me thoroughly whats the use of oldstudent that you use? i want to understand what you did.

and also this one? is this an array?

Quote

Con.Execute(String.Format("UPDATE StudentInfo SET StudentNo='{0}', LastName = '{1}',FirstName = '{2}', Course = '{3}', Status = '{4}', YearLvl = '{5}' Where StudentNo ='{6}'", txtStudNo.Text.Trim, txtLN.Text.Trim, txtFN.Text.Trim, txtCourse.Text.Trim, txtStatus.Text.Trim, txtYr.Text.Trim, OldStudentNo)) MsgBox("Successfully saved", MsgBoxStyle.Information, "")
Me.Close()


my problem now is how to understand this. :sweatdrop:
Was This Post Helpful? 0
  • +
  • -

#17 emresutisna  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 21
  • View blog
  • Posts: 80
  • Joined: 14-May 09

Re: Update Syntax Problem

Posted 04 September 2010 - 05:29 AM

OldStudentNo is just a variable to store a StudentNo value before you change it. So, you can update the data you mean to be updated. If you dont know the StudentNo to be updated, you'll update the whole datas in your table. For example, you have data :
StudentNo | Name
08.001 Emresutisna
08.002 mpe-IT

And you want to update data with StudentNo "08.001" to be "08.003". So, before you update the data you should store the OldStudentNo ("08.001") to ensure you update only the right data. Look at these steps :
1. Store your Primary Key Old Data --> OldStudentNo = "08.001"
2. Change your TextBox value, then update the database
Con.Execute("UPDATE StudentInfo SET StudentNo='08.003', Name = 'Emresutisna' Where StudentNo='" & OldStudentNo & "'")

String.Format is a function to make a string easier to read For Ex :
Before : "My Fullname is =" & txtFull.Text & ", Lastname = " & txtLast.Text & ", FirstName = " & txtFirst.Text
After : String.Format("My Fullname is {0}, LastName = {1}, Firstname = {2}", txtFull.Text, txtLast.Text, txtFirst.Text)

Look at the ex above, it's easier to understand if we use String.Format.

Hope it's clear.
And now could you give me some rate :smile2:
Was This Post Helpful? 1
  • +
  • -

#18 mpe-IT  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 152
  • Joined: 27-November 09

Re: Update Syntax Problem

Posted 04 September 2010 - 06:33 AM

thank you so much! i hope that i can be like you someday! rate? SURE! no problem :)

oh btw, as you see my program(you've download it right? :P ) why is it when the mainform loads, the listview doesnt show me what i wanted, wherein i put this code already
 Private Sub InitLVHeader()
        With ListView1.Columns
            .Add("ID").Width = 0
            .Add("Student No.")
            .Add("Lastname")
            .Add("Firstname")
            .Add("Course")
            .Add("Status")
            .Add("Year Level")
        End With
    End Sub

This post has been edited by mpe-IT: 04 September 2010 - 07:39 AM

Was This Post Helpful? 0
  • +
  • -

#19 emresutisna  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 21
  • View blog
  • Posts: 80
  • Joined: 14-May 09

Re: Update Syntax Problem

Posted 04 September 2010 - 07:50 AM

It hapens because your ListView.View property is still set to "LargeIcon". Try to change the value to "Details". You can modify the "InitLVHeader" to be like this :
    Private Sub InitLVHeader()
        With ListView1.Columns
            .Add("ID").Width = 0
            .Add("Student No.")
            .Add("Lastname")
            .Add("Firstname")
            .Add("Course")
            .Add("Status")
            .Add("Year Level")
        End With
        ListView1.View = View.Details
    End Sub



To give rate just click "+" symbol in "Was This Post Helpfull?" at the bottom of my post.

My pleasure to help you...

This post has been edited by emresutisna: 04 September 2010 - 07:51 AM

Was This Post Helpful? 1
  • +
  • -

#20 mpe-IT  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 152
  • Joined: 27-November 09

Re: Update Syntax Problem

Posted 04 September 2010 - 08:32 AM

after changing it to details i cant select item in the listview, why?
Was This Post Helpful? 0
  • +
  • -

#21 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1605
  • View blog
  • Posts: 5,162
  • Joined: 25-September 09

Re: Update Syntax Problem

Posted 04 September 2010 - 09:30 AM

By Default, the Listview in details view allows you to select the left-most column, try setting .FullRowSelect to true in the listview properties.
Was This Post Helpful? 1
  • +
  • -

#22 emresutisna  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 21
  • View blog
  • Posts: 80
  • Joined: 14-May 09

Re: Update Syntax Problem

Posted 04 September 2010 - 04:22 PM

just do what charliemay said. Change the listview1.FullRowSelect = True to make your listview being able to be selected per row
Was This Post Helpful? 0
  • +
  • -

#23 mpe-IT  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 152
  • Joined: 27-November 09

Re: Update Syntax Problem

Posted 04 September 2010 - 08:52 PM

thank you guys you really helped me a lot!
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2