为什么我的更新不行?
<Script runat="server">
Sub Page_Load(obj as object , e as eventArgs)
If Session("username") ="" then
Response.Redirect("../Login.aspx")
End If
SessionUser.text =""& Session("Username") &""
Dim int As Int32 = Cint(Request.Querystring("id"))
Dim mySqlConnection As SqlConnection=new SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
Dim myDs As New DataSet()
Dim mySqlCommand As New SqlDataAdapter("Select * From companyinfo where id="& int,mySqlConnection)
mySqlConnection.open()
mySqlCommand.Fill(myDs,"companyinfo")
mySqlConnection.Close()
txtcompany.text = myDs.Tables("companyinfo").Rows(0)("name")
txtaddress.text = myDs.Tables("companyinfo").Rows(0)("address")
txttel.text = myDs.Tables("companyinfo").Rows(0)("tel")
txtfax.text = myDs.Tables("companyinfo").Rows(0)("fax")
txtemail.text = myDs.Tables("companyinfo").Rows(0)("email")
txthomepage.text = myDs.Tables("companyinfo").Rows(0)("homepage")
txtlinkman.text = myDs.Tables("companyinfo").Rows(0)("linkman")
txtproduct.text = myDs.Tables("companyinfo").Rows(0)("product")
txtkeyword.text = myDs.Tables("companyinfo").Rows(0)("keyword")
txtbrief.text = myDs.Tables("companyinfo").Rows(0)("brief")
End Sub
Sub Btn_Click(Sender as object, e As EventArgs)
Dim int As Int32 = Cint(Request.Querystring("id"))
Dim mySqlConnection As SqlConnection=new SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
Dim StrSql As String = "update companyinfo set name=@name,address=@address,tel=@tel,fax=@fax,email=@email,homepage=@homepage,linkman=@linkman,product=@product,keyword=@keyword,brief=@brief,date=@date where id=" & int &""
Dim mySqlCommand As New SqlCommand(StrSql, mySqlConnection)
mySqlCommand.Parameters.Add("@name",SqlDbType.Varchar).Value = txtcompany.text
mySqlCommand.Parameters.Add("@address",SqlDbType.Varchar).Value = txtaddress.text
mySqlCommand.Parameters.Add("@tel",SqlDbType.Varchar).Value = txttel.text
mySqlCommand.Parameters.Add("@fax",SqlDbType.Varchar).Value =txtfax.text
mySqlCommand.Parameters.Add("@email",SqlDbType.Varchar).Value = txtemail.text
mySqlCommand.Parameters.Add("@homepage",SqlDbType.Varchar).Value = txthomepage.text
mySqlCommand.Parameters.Add("@linkman",SqlDbType.Varchar).Value = txtlinkman.text
mySqlCommand.Parameters.Add("@product",SqlDbType.Varchar).Value = txtproduct.text
mySqlCommand.Parameters.Add("@keyword",SqlDbType.Varchar).Value = txtkeyword.text
mySqlCommand.Parameters.Add("@brief",SqlDbType.Varchar).Value = txtbrief.text
mySqlCommand.Parameters.Add("@date",SqlDbType.Varchar).value = formatdatetime(datetime.now,2)
'Response.write (StrSql)
'Response.End
mySqlConnection.Open()
mySqlCommand.ExecuteNonQuery()
mySqlConnection.Close()
Response.Redirect("companyinfo_defau.aspx")
Response.End
End Sub
</Script>