|
The script source code is as follows:
<script runat = "server">
string strcnn = "server = localhost; uid = sa; pwd = wbq; database = WebDate_WBQ";
SqlConnection cnn;
SqlCommand cmd;
void Page_Load (object sender, EventArgs e) {
string userID = Request.QueryString ["userID"];
cnn = new SqlConnection (strcnn);
cnn.Open ();
cmd = new SqlCommand ("select * from users where userID =" + userID + "", cnn);
SqlDataReader dr = cmd.ExecuteReader ();
Label1.Text = dr ("userID"). ToString (); // The following code is wrong.
TextBox1.Text = dr ("userName"). ToString ();
TextBox2.Text = dr ("pwd"). ToString ();
TextBox3.Text = dr ("sex"). ToString ();
TextBox4.Text = dr ("regDate"). ToString ();
TextBox5.Text = dr ("QQ"). ToString ();
TextBox6.Text = dr ("email"). ToString ();
TextBox7.Text = dr ("address"). ToString ();
dr.Close ();
cnn.Close ();
}
</ script>
The compilation error message is as follows:
Compile Error
Explanation: An error occurred during the compilation of the resources required to service the request. Please check the following specific error details and modify the source code appropriately.
Compiler Error Message: CS0118: "dr" means "variable" and should be "method" here
Source error:
Line 18: cmd = new SqlCommand ("select * from users where userID =" + userID + "", cnn);
Line 19: SqlDataReader dr = cmd.ExecuteReader ();
Line 20: Label1.Text = dr ("userID"). ToString ();
Line 21: TextBox1.Text = dr ("userName"). ToString ();
Line 22: TextBox2.Text = dr ("pwd"). ToString (); |
|