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