- 论坛徽章:
- 0
|
c# 使用odbccommand调用mysql存储过程
代码如下 发生若干问题 无法解决
,有解决的麻烦贴完整代码,我有时间也会贴出
string MyConString = "DRIVER={MySQL ODBC 3.51 Driver};" +
"SERVER=localhost;" +
"DATABASE=test;" +
"UID=root;" +
"PASSWORD=888888;" +
"OPTION=3";
OdbcConnection conn = new OdbcConnection(MyConString);
conn.Open();
OdbcCommand cmd = new OdbcCommand();
cmd.Connection = conn;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "p_text";
OdbcParameter p1 = new OdbcParameter("t_count", OdbcType.Int);
p1.Direction = ParameterDirection.Output;
cmd.Parameters.Add(p1);
int i = cmd.ExecuteNonQuery();
TextBox1.Text = p1.Value.ToString();
conn.Close();
存储过程:
SQL code
?
1
2
3
4
create procedure p_text (out t_count int)
begin
select count(*) into t_count from text;
end |
|