public static int GetScalar(string sql,params OracleParameter [] OracleParms)

{

using (OracleConnection conn = new OracleConnection(conStr))

{

if (conn.State == System.Data.ConnectionState.Closed)

{

conn.Open();

}

OracleCommand cmd = new OracleCommand(sql, conn);

cmd.Parameters.AddRange(OracleParms);

return Convert.ToInt32(cmd.ExecuteScalar());

}

}

OracleParameter p1 = new OracleParameter(":username", OracleDbType.Varchar2);

p1.Value = username;

OracleParameter p2 = new OracleParameter(":password", OracleDbType.Varchar2);

p2.Value = password;

if (OracleHelper.GetScalar("select count(*) from user_info where name=:username and password=:password", p1, p2) == 1)

{

MessageBox.Show("登錄成功");

}

SqlServer中使用@来进行占位,oracle中使用:占位。

标签:username,p2,C#,数据库,OracleParameter,new,password,conn

来源: https://www.cnblogs.com/monkey6/p/12222621.html

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐