vb.net update query how to
-
hey everyone, i am writing an application in vb.net i use web matrix to generate my querys, when i run an update query and use it it only update information that is not yet in the database that is.. if the field is empty then it will update it...but if there is information in the field..how do i up date it using a sql update statement
Nab
-
hey everyone, i am writing an application in vb.net i use web matrix to generate my querys, when i run an update query and use it it only update information that is not yet in the database that is.. if the field is empty then it will update it...but if there is information in the field..how do i up date it using a sql update statement
Nab
Is it an update query or an insert query that you have? When you say "field", do you really mean a field, or do you mean a record? When you say that it's "empty", is it a field that is null, a field that is empty, or a record that doesn't exist? An insert query will only add new records. An update query will only update records that exist, not create new ones. An update query will always update the values in the fields if the record exist, regardless of what the values were before.
--- single minded; short sighted; long gone;
-
Is it an update query or an insert query that you have? When you say "field", do you really mean a field, or do you mean a record? When you say that it's "empty", is it a field that is null, a field that is empty, or a record that doesn't exist? An insert query will only add new records. An update query will only update records that exist, not create new ones. An update query will always update the values in the fields if the record exist, regardless of what the values were before.
--- single minded; short sighted; long gone;
its and update query.. and it giving me problem updating.. example.. in my project.. say i have three fields in the table..firstname, lastname, and middle name.. first name and lastname is monditary so information will always be in the table for first and last name.. and middle name might not have informaiton... i use webmatrix to create my query and then place it in a class in my project then called it where it is needed.. problem: when i try to run an update.. if i try to update a record.. say John Brown is the person's name..if i try to change it to say..mary brown..its not updating..but if i try to change it to John James Brown..note this time, i only updated the middle name because before it didn't have one.. in this case it updates.. so i am wondering whats up with my query.. could u write me a simple update query and let me see if i can use it to test my project..becuase the generated ones not helping me.. thanks..
Nab
-
its and update query.. and it giving me problem updating.. example.. in my project.. say i have three fields in the table..firstname, lastname, and middle name.. first name and lastname is monditary so information will always be in the table for first and last name.. and middle name might not have informaiton... i use webmatrix to create my query and then place it in a class in my project then called it where it is needed.. problem: when i try to run an update.. if i try to update a record.. say John Brown is the person's name..if i try to change it to say..mary brown..its not updating..but if i try to change it to John James Brown..note this time, i only updated the middle name because before it didn't have one.. in this case it updates.. so i am wondering whats up with my query.. could u write me a simple update query and let me see if i can use it to test my project..becuase the generated ones not helping me.. thanks..
Nab
Here is an update query that you can use:
Dim queryString As String = "UPDATE [R_Application] SET [Fname]=@Fname, [Mname]=@Mname, [Lname]=@Lname WHERE (" & _
"[R_Application].[AppId] = @AppId)"As you see, this is the same as you posted in your other thread. There is nothing wrong with it. As I said in the other thread, you have to look for the error elsewhere in the code. Debug the code and look carefully where you get the values from that you put in the parameters for the database call. I suspect that what you actually put in the parameters is the exact values that you find in the database.
--- single minded; short sighted; long gone;