Results 1 to 6 of 6

Thread: [RESOLVED] [2005] databse is not updating!!

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2004
    Location
    philippines
    Posts
    245

    Resolved [RESOLVED] [2005] databse is not updating!!

    Please take a look at this.. my sql string executes well if i try to execute it using mssql query but when i execute it through code.. it never returns an error nor updates the database..

    VB Code:
    1. Dim tmpstr As String = getstdemail()
    2.             Dim sqlc As New SqlConnection("Data Source=KABUNYAWAN\SQLEXPRESS;Initial Catalog=ojt;Integrated Security=True;Pooling=False")
    3.             'Dim sqla As New SqlDataAdapter("update stdMaster set fname = '" & txtfname.Text & "' , lname = '" & txtlname.Text & "' , address = '" & txtaddress.Text & "' , age = " & txtage.Text & " , sex = '" & txtsex.Text & "' , syr = '" & txtyear.Text & "' , slvl = '" & txtlvl.Text & "' , email = '" & txtemail.Text & "' , hometel = '" & txthome.Text & "' , cellnum = '" & txtcell.Text & "' where email  = '" & getstdemail() & "'", sqlc)
    4.             Dim sqlcom As New SqlCommand("update stdMaster set fname = '" & txtfname.Text & "' , lname = '" & txtlname.Text & "' , address = '" & txtaddress.Text & "' , age = " & txtage.Text & " , sex = '" & txtsex.Text & "' , syr = '" & txtyear.Text & "' , slvl = '" & txtlvl.Text & "' , email = '" & txtemail.Text & "' , hometel = '" & txthome.Text & "' , cellnum = '" & txtcell.Text & "' where email  = '" & tmpStr & "'", sqlc)
    5.  
    6.             sqlcom.Connection.Open()
    7.             sqlcom.ExecuteNonQuery()
    8.             sqlcom.Connection.Close()

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,344

    Re: [2005] databse is not updating!!

    On what are you basing this? Have you performed a query immediately afterwards? Have you tested the return value of ExecuteNonQuery, which indicates the number of rows affected? Have you checked that the e-mail address you're providing in the WHERE clause actually exists?

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2004
    Location
    philippines
    Posts
    245

    Re: [2005] databse is not updating!!

    this is what my query looks like :

    VB Code:
    1. update stdMaster set fname = 'Ryanss ', lname = 'Flores ', mi = 'S ', address = 'AMA East Rizal ', pob = 'Marikin ', age = 23, sex = 'M', email = 'SeaBlood_Shed@yahoo.com ', hometel = '9982601 ', cellnum = '09062907017 ', prevsch = 'AMA East Rizal ', comadd = 'AMA Cainta ', faname = 'Hermie R. Flores ', fareligion = 'Christian ', faedat = 'College ', faocc = 'SCADA Engineer ', fapow = 'SAUDI ', faotel = 'N/A ', maname = 'Ma. Elena S. Flores ', mareligion = 'Christian ', maedat = 'College ', maocc = 'N/A ', mapow = 'N/A ', maotel = 'N/A ' where email = 'SeaBlood_Shed@yahoo.com'

    email is correct.. well that's odd.. i already changed fname to asdf(from a textbox) but still after clicking update the previous valuw of the textbox is retained.. hmmmm

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,344

    Re: [2005] databse is not updating!!

    And... what of my other questions? Also, you should learn how to write parameterised SQL statements. Look up the SqlParameter class for more information.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jan 2004
    Location
    philippines
    Posts
    245

    Re: [2005] databse is not updating!!

    i solved it.. i was calling a proceedure at page_load which apparently blocks all my database calls like insert..update statements..

    to resolve :

    I placed my code from page_load to page_init. Hehehe that's it.. that made it work perfectly fine..

    @jmcilhinney - thanks for the tip.. i will see to it that i will learn that.. for now.. i'll stick with this.. i just learned asp.net.. last week.. hehe newbie i am.. thanks very much..

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,344

    Re: [RESOLVED] [2005] databse is not updating!!

    Given that there is an ASP.NET forum, if you post in a language forum most people will assume that it's a WinForms app unless you specify otherwise.

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