尝试将代码从aspx页面移到后面的代码中。似乎无法追查我为Compiler Error Message: BC30451: Name 'UID' is not declared.
AccessDataSource1.UpdateParameters.Add("UID", DbType.Int32, UID)
的原因
我需要移动除GridView控件之外的所有控件。我看过How to pass variable to SelectCommand of SqlDataSource?但没有解决错误。
Imports Microsoft.VisualBasic
Imports System.Data
Imports System.Net.Mail
Partial Class _a_edit_students_revised1
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
AccessDataSource1.SelectCommand = "SELECT [UID], [StudentID], [UserName], [LastName], [FirstName], [HomePhone], [Affiliation], [Email], [Active], [Career], [VolAdmin] FROM [UsersDataTbl] ORDER BY [LastName]"
AccessDataSource1.DeleteCommand = "DELETE FROM [UsersDataTbl] WHERE [UserName] = ?"
AccessDataSource1.UpdateCommand = "UPDATE UsersDataTbl SET UID = @UID, StudentID = @StudentID, LastName = @LastName, FirstName = @FirstName, HomePhone = @HomePhone, Affiliation = @Affiliation, Email = @Email, Active = @Active, Career = @Career, VolAdmin = @VolAdmin WHERE UserName = @UserName"
'AccessDataSource1.SelectParameters.Add("userId", userId.ToString());
AccessDataSource1.UpdateParameters.Add("UID", DbType.Int32, UID)
AccessDataSource1.UpdateParameters.Add("StudentID", StudentID.ToString())
AccessDataSource1.UpdateParameters.Add("LastName", LastName.ToString())
AccessDataSource1.UpdateParameters.Add("FirstName", FirstName.ToString())
AccessDataSource1.UpdateParameters.Add("HomePhone", HomePhone.ToString())
AccessDataSource1.UpdateParameters.Add("Affiliation", Affiliation.ToString())
AccessDataSource1.UpdateParameters.Add("Email", Email.ToString())
AccessDataSource1.UpdateParameters.Add("Active", Active.ToString())
AccessDataSource1.UpdateParameters.Add("Career", Career.ToString())
AccessDataSource1.UpdateParameters.Add("VolAdmin", VolAdmin.ToString())
AccessDataSource1.UpdateParameters.Add("UserName", UserName.ToString())
'SqlDataSource1.ConnectionString = ConfigurationManager.ConnectionStrings["MyConString"].ConnectionString
End Sub
End Class