1. Add Reference MySql.Data.dll
2. Type the code :
public List
{
List
string spName = "GetDataMahasiswa";
// Connection String
string connString = "SERVER=localhost;" +
"DATABASE=myfirst;" +
"UID=root;" +
"PASSWORD=123;";
MySqlConnection conn = new MySqlConnection(connString);
MySqlCommand command = conn.CreateCommand();
MySqlDataReader reader;
command.CommandText = "call " + spName + "('9')";
conn.Open();
reader = command.ExecuteReader();
if (reader.HasRows)
{
listNama = new List
while (reader.Read())
{
// Read the value...
//string value = reader.GetValue(0).ToString();
string value = reader["Nama"].ToString().Trim();
listNama.Add(value);
}
}
conn.Close();
return listNama;
}
Okay, may it helps
No comments:
Post a Comment