hai..i cannot solve this sproblem...i need to update my databse after i edited the textfield.then system will return me 'UPDATE SUCCESS'(because i return value UPDATE SUCCESS).this seem like nothing wrong.but when i check the database,data did not update!!have anybody know that?
thanks!!my coding as below,
#Region "Edit student Then save"
Public Function editstudent(ByVal sIC As String, ByVal school As String, ByVal phone As String, ByVal pic As String, ByVal pwd As String, ByVal sname As String, ByVal gender As String, ByVal add As String, ByVal standard As String, ByVal osic As String) As String
' Create Instance of Connection and Command Object
Dim myConnection As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
Dim command As String
Dim mycommand As SqlCommand
command = "Update student_info set sic=@.sic, Spassword=@.pwd," & _
"sname=@.sname,sphone=@.phone,saddress=@.add,sstandard=@.standard,sschool=@.school ,Sparent_IC=@.pic ,sGender=@.gender Where sic=@.osic"
mycommand = New SqlCommand(command, myConnection)
mycommand.CommandType = CommandType.Text
'' Add Parameters to Command
Dim parameterIC As SqlParameter = New SqlParameter("@.sic", SqlDbType.VarChar, 12)
parameterIC .Value = sIC
mycommand.Parameters.Add(parameterIC )
Dim parameteroIC As SqlParameter = New SqlParameter("@.osic", SqlDbType.VarChar, 12)
parameteroIC .Value = osic
mycommand.Parameters.Add(parameteroIC )
Dim parameterpwd As SqlParameter = New SqlParameter("@.pwd", SqlDbType.VarChar, 50)
parameterpwd .Value = pwd
mycommand.Parameters.Add(parameterpwd )
Dim parametername As SqlParameter = New SqlParameter("@.sname", SqlDbType.VarChar, 100)
parametername .Value = sname
mycommand.Parameters.Add(parametername )
Dim parameteradd As SqlParameter = New SqlParameter("@.add", SqlDbType.VarChar, 100)
parameteradd .Value = add
mycommand.Parameters.Add(parameteradd )
Dim parameterphone As SqlParameter = New SqlParameter("@.phone", SqlDbType.VarChar, 12)
parameterphone.Value = phone
mycommand.Parameters.Add(parameterphone)
Dim parameterstandard As SqlParameter = New SqlParameter("@.standard", SqlDbType.VarChar, 50)
parameterstandard.Value = standard
mycommand.Parameters.Add(parameterstandard)
Dim parametersschool As SqlParameter = New SqlParameter("@.school", SqlDbType.VarChar, 100)
parametersschool.Value = school
mycommand.Parameters.Add(parametersschool)
Dim parameterpic As SqlParameter = New SqlParameter("@.pic", SqlDbType.VarChar, 12)
parameterpic.Value = pic
mycommand.Parameters.Add(parameterpic)
Dim parametergender As SqlParameter = New SqlParameter("@.gender", SqlDbType.VarChar, 1)
parametergender.Value = gender
mycommand.Parameters.Add(parametergender)
Try
myConnection.Open()
mycommand.ExecuteNonQuery()
myConnection.Close()
Return "Update Success !!!"
Catch exc As Exception
Return exc.ToString
End Try
End Function
#End Region
End Class
Hi,
It is a working code on my tests.
Open the sql profiler and trace your statement. If you do not see your sql command in the profiler then check the connection string.
If it is listed in the profiler screen then use that sql statement to improve your results.
(hint for profiler, change the name of the column "password" to "pwd" otherwise sql will not be listed in the profiler)
Eralper
|||Sound like the following is the cause of your confusion:
Depending on how you have your debugging environment set up, when you start your application, it makes a copy of all your source files somewhere else, then runs it. When that happens it also happens to make a copy of your database, so your applications makes changes to the new copy of the database, but whatever tool you are using to check the database is looking at the original. Of course restarting the application causes it to copy over the new copy with the original again.
No comments:
Post a Comment