enter code here
我很难将 web 方法传递给标签。我也使用 sql 将信息传递给标签。你们能帮帮我吗?
这是我的网络方法。
public string[] GetCPname(string cpname)
{
OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source= C:\\Temp\\StudentsDatabase.mdb");
conn.Open();
//Get the ID of the selected book.
OleDbCommand cmd = new OleDbCommand("SELECT ID FROM Student where Name = @name", conn);
cmd.Parameters.AddWithValue("@name", cpname);
OleDbDataReader reader = cmd.ExecuteReader();
reader.Read();
int cpNameID = reader.GetInt32(0);
//Get all the reviews with the Book_ID selected.
cmd = new OleDbCommand("SELECT CPname FROM StudentInformation where ID = @id", conn);
cmd.Parameters.AddWithValue("@id", cpNameID);
reader = cmd.ExecuteReader();
ArrayList result = new ArrayList();
while (reader.Read())
{
result.Add(reader.GetString(0));
}
// Disconnect from DB
reader.Close();
conn.Close();
// Convert ArrayList to string array and return
return result.ToArray(typeof(string)) as string[];
}
This is my coding to pass to the label.
protected void retrievecpname(string CP)
{
StudentsWSRef.StudentsWS ws = new StudentsWSRef.StudentsWS();
string[] x = ws.GetStudentNames();
lblcpName.Text = CP;
}
我对这段代码有疑问,因为它仍然没有将信息传递给标签。