Hey guys,
I'm trying to update my database with values in text fields on my .aspx page.
I'm used to java so I'm struggling to figure out whats wrong with this.
Inherits System.Web.UI.Page
Dim conn As SqlConnection
Dim cmd As SqlCommand
Dim dst As DataSet
Dim dad As SqlDataAdapter
Dim strSql As String
Dim strConn As String = "server=xxx\xxx;database=xxx;uid=xxx;pwd=xxx"
Sub updateEmployee()
strSql = String.Format("UPDATE tblemployee SET login='"TxtLogin.Text"', password='"TxtPassword.Text"', statusid='"TxtStatusId.Text"', fullname='"TxtFullname.Text"', branchid='"TxtBranchId.Text"' WHERE employeeid={0}", radioEmp.SelectedItem.Value)
conn = New SqlConnection(strConn)
cmd = New SqlCommand(strSql, conn)
conn.Open()
cmd.ExecuteNonQuery()
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
dst = New DataSet
strSql = ("select employeeid, fullname from tblEmployee")
conn = New SqlConnection(strConn)
dad = New SqlDataAdapter(strSql, conn)
dad.Fill(dst, "tblemployee")
radioEmp.DataSource = dst
radioEmp.DataTextField = "fullname"
radioEmp.DataValueField = "employeeid"
radioEmp.DataBind()
End Sub
Basically, on page_load, a list of employees is generated and you can select them with radio buttons. Whichever that is selected, i want updating. So ive got some text fields, and whatever is in there, i want updateStaff() to update it. But its underlining my update SQL statement saying this:
sql error
any ideas?
I'm trying to update my database with values in text fields on my .aspx page.
I'm used to java so I'm struggling to figure out whats wrong with this.
Inherits System.Web.UI.Page
Dim conn As SqlConnection
Dim cmd As SqlCommand
Dim dst As DataSet
Dim dad As SqlDataAdapter
Dim strSql As String
Dim strConn As String = "server=xxx\xxx;database=xxx;uid=xxx;pwd=xxx"
Sub updateEmployee()
strSql = String.Format("UPDATE tblemployee SET login='"TxtLogin.Text"', password='"TxtPassword.Text"', statusid='"TxtStatusId.Text"', fullname='"TxtFullname.Text"', branchid='"TxtBranchId.Text"' WHERE employeeid={0}", radioEmp.SelectedItem.Value)
conn = New SqlConnection(strConn)
cmd = New SqlCommand(strSql, conn)
conn.Open()
cmd.ExecuteNonQuery()
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
dst = New DataSet
strSql = ("select employeeid, fullname from tblEmployee")
conn = New SqlConnection(strConn)
dad = New SqlDataAdapter(strSql, conn)
dad.Fill(dst, "tblemployee")
radioEmp.DataSource = dst
radioEmp.DataTextField = "fullname"
radioEmp.DataValueField = "employeeid"
radioEmp.DataBind()
End Sub
Basically, on page_load, a list of employees is generated and you can select them with radio buttons. Whichever that is selected, i want updating. So ive got some text fields, and whatever is in there, i want updateStaff() to update it. But its underlining my update SQL statement saying this:
sql error
any ideas?