forms验证
oracle 数据库
C# 开发
(连接数据库,验证用户,加验证码更好)单独写在一个引用类里面: classPro/test/User_Login;
验证函数返回一个值(int/bool);再在Login.aspx.cs里根据这个值进行判断,并抛出各种错误输入.
成功的话进入首页.是高手的100分全拿去!!!email: [email protected]
oracle 数据库
C# 开发
(连接数据库,验证用户,加验证码更好)单独写在一个引用类里面: classPro/test/User_Login;
验证函数返回一个值(int/bool);再在Login.aspx.cs里根据这个值进行判断,并抛出各种错误输入.
成功的话进入首页.是高手的100分全拿去!!!email: [email protected]
{
SqlConnection conn = Connect .GetSqlconnection ();
SqlCommand cmd = new SqlCommand ();
cmd.CommandText = "select Password from TBL_AdminInfo where AdminID = @id";
cmd.Parameters .Add ("@id",id.Trim ());
cmd.Connection =conn;
conn.Open ();
SqlDataReader reader = cmd.ExecuteReader ();
while(reader.Read() )
{
if(reader["Password"].ToString ().Trim ()== pwd.Trim ())
{
Search.Pass=true;
}
else
Search.Pass=false;
}大概这样把,Connect .GetSqlconnection ()的连接ORACLE的东西自己写拉然后在Login窗体判断Search.Pass是通过自己可以加点判断,大概这样了
{
try
{
String connstr="Driver={Microsoft ODBC for Oracle};Server=OracleServer.world;Uid=Username;Pwd=asdasd;"
SqlConnection cn=new SqlConnection(constr);
SqlCommand cmd=cn.CreateCommand();
cmd.Commandtext="Select U_ID,U_Password from Tb_USER where U_ID='"+textBox1.text+"'and "+
"U_Password='"+textBox2.text+"'";
SqlDataReader mrd=cmd.ExecuteReader();
if(myread.read())
{
MessageBox.Show("通过检测");
}
}
catch(DataException ex)
{
Messagebox.Show(ex.Message);
}
finally
{
if(cn!=null)
{
cn.close();
}
}
}
using System.Data;
using System.Data.OracleClient;//这个需要手动添加,默认是没有的,在工程的引用中先添加,然后在类文件的开头using一下using System;
using System.Data;
using System.Data.OleDb;
String sConnectionString =
"Provider=MSDAORA.1;User ID=myUID;password=myPWD;
Data Source=myOracleServer;Persist Security Info=False";
String mySelectQuery =
"SELECT * FROM TestTable where c1 LIKE ?";
OleDbConnection myConnection = new OleDbConnection(sConnectionString);
OleDbCommand myCommand = new OleDbCommand(mySelectQuery, myConnection);
myCommand.Parameters.Add("@p1", OleDbType.Char, 5).Value = "Test%";
myConnection.Open();
OleDbDataReader myReader = myCommand.ExecuteReader();
int RecordCount=0;
try
{
while (myReader.Read())
{
RecordCount = RecordCount + 1;
MessageBox.Show(myReader.GetString(0).ToString());
}
if (RecordCount == 0)
{
MessageBox.Show("No data returned");
}
else
{
MessageBox.Show("Number of records returned:" + RecordCount);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
finally
{
myReader.Close();
myConnection.Close();
}