0
enter code here
我很難將網絡方法傳遞給標籤。我也使用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;
}
我得到這個代碼的問題,因爲它仍然沒有將信息傳遞給標籤。
你究竟想要傳遞給標籤?你不能傳遞一個方法。你只能設置你想要的屬性。 – ryadavilli
你在哪裏調用了「retrievecpname」函數?我在你的代碼中找不到它 – babooney
我不理解這段代碼,你如何處理'retrievecpname'中的'x'? – JonH