<%@ Page Language="C#" Debug="true"%> <%@ Import Namespace="System.Data.OleDb" %> <% string sConn; sConn= @"Provider=Microsoft.Jet.Oledb.4.0;Data Source=C:/emp.mdb"; string sql=@"select [name] from emp where EmpID=@EmpID"; string empName; int sEmpId=25; OleDbConnection conn=new OleDbConnection(sConn); OleDbCommand cmd=new OleDbCommand(sql,conn); cmd.Parameters.Add("@EmpID",OleDbType.Integer); cmd.Parameters["@EmpID"].Value=sEmpId; conn.Open(); empName=cmd.ExecuteScalar().ToString(); conn.Close(); Response.Write(empName); %> |
