home

Asp.net Sql Update Tutorial


'Declare and create an instance of the object(CON) from the SqlConnetion Class
Dim CON as New SqlConnection("server= webserve;database=student;uid=student;pwd=icc;")

'Declare variable(SQL) and assign its value
Dim SQL as String="Update Products set pname=@name,pprice=@price where pid=@id"

CMD.Parameters.Add(New SqlParameter(“@id”,SqlDBType.Int))
CMD.Parameters(“@id”).Value = ProdID.text

CMD.Parameters.Add(New SqlParameter(“@name”,SqlDBType.Varchar,30))
CMD.Parameters(“@name”).Value = ProdName.text

CMD.Parameters.Add(New SqlParameter(“@price”,SqlDBType.Decimal,30))
CMD.Parameters(“@price”).Value = ProdPrice.text

'Declare and create an instance of the object(CMD) from SqlCommand Class
Dim CMD as New SqlCommand (SQL,CON)

'Execute Insert
Con.open()
CMD.ExecuteNonQuery()
Con.close()

‘ Display a message to the user
msg.text="Record Updated Successfully"


Content on this page requires a newer version of Adobe Flash Player.

Get Adobe Flash player

all rights reseverd by Cramerz.com©. web development by web design company DotPeak. hosting by HostBay
all contents on cramerz are the property of Cramerz.com. web design courses