http://www.csharp-station.com/Tutorials/AdoDotNet/Lesson07.aspx
http://www.c-sharpcorner.com/UploadFile/pk_khuman/ManagedStoredProceduresUsingCSharp02182007232059PM/ManagedStoredProceduresUsingCSharp.aspx
http://www.programmingado.net/a-133/Fetching-MySQL-data-through-stored-procedures.aspx
DELIMITER $$
DROP PROCEDURE IF EXISTS `db_test`.`City_GetByCountry`$$
CREATE PROCEDURE `db_test`.`City_GetByCountry` (p_in_country_id int)
BEGIN
select * from city where country_id=p_in_country_id;
END$$
DELIMITER ;
public DataTable GetDataSP_MySQL(long in_country_id)
{
MySql.Data.MySqlClient.MySqlConnection oConn = new MySql.Data.MySqlClient.MySqlConnection();
oConn.ConnectionString = "Database=sakila;Data Source=192.168.10.4;User id=stefan;Password=pekka"; oConn.Open();
DataSet oDataSet = new System.Data.DataSet("tab1");
//Get data
MySql.Data.MySqlClient.MySqlCommand command = new MySql.Data.MySqlClient.MySqlCommand("City_GetByCountry", oConn);
command.Parameters.Add(new MySql.Data.MySqlClient.MySqlParameter("?p_in_country_id", DbType.Int32));
// Now, add a value to it and later execute the command as usual.
command.Parameters[0].Value = in_country_id;
command.CommandType = CommandType.StoredProcedure;
MySql.Data.MySqlClient.MySqlDataAdapter oAdapter =
new MySql.Data.MySqlClient.MySqlDataAdapter(command);
oAdapter.Fill(oDataSet, "tab1");
DataTable dt = oDataSet.Tables["tab1"];
oConn.Close();
return dt;
}
http://dev.mysql.com/doc/refman/5.0/en/create-procedure.html
mysql> delimiter //
mysql> CREATE PROCEDURE simpleproc (OUT param1 INT)
-> BEGIN
-> SELECT COUNT(*) INTO param1 FROM t;
-> END//
Query OK, 0 rows affected (0.00 sec)
mysql> delimiter ;
mysql> CALL simpleproc(@a);
Query OK, 0 rows affected (0.00 sec)
mysql> SELECT @a;
+------+
@a
+------+
3
+------+
1 row in set (0.00 sec)
Abonner på:
Legg inn kommentarer (Atom)
Ingen kommentarer:
Legg inn en kommentar