FYI see below code
=============================
public void AddRequest(Common comObj)
{
string conString = ConfigurationManager.AppSettings
["ConnectionString"];
using (SqlConnection con = new SqlConnection(conString))
{
if (con.State == ConnectionState.Closed)
con.Open();
SqlCommand cmd = new SqlCommand("sp_BookConferenceHall",
con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@ip_EmpNo", comObj.EmpNo);
cmd.Parameters.AddWithValue("@ip_Name", comObj.Name);
cmd.Parameters.AddWithValue("@ip_Team", comObj.Team);
cmd.Parameters.AddWithValue("@ip_ConferencePlace",
comObj.ConferencePlace);
cmd.Parameters.AddWithValue("@ip_FromTime",
comObj.FromTime);
cmd.Parameters.AddWithValue("@ip_ToTime", comObj.ToTime);
cmd.Parameters.AddWithValue("@ip_TotalTime",
comObj.TotalTime);
cmd.Parameters.AddWithValue("@ip_Projector",
comObj.Projector);
cmd.Parameters.AddWithValue("@ip_OtherRequirements",
comObj.OtherRequirements);
cmd.Parameters.AddWithValue("@ip_Status", comObj.Status);
cmd.ExecuteNonQuery();
}
}
=============================
public static Common GetObj(int id)
{
Common comObj = new Common();
string conString = ConfigurationManager.AppSettings
["ConnectionString"];
using (SqlConnection con = new SqlConnection(conString))
{
if (con.State == ConnectionState.Closed)
con.Open();
SqlCommand command = new SqlCommand("sp_GetCommonObj",
con);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.AddWithValue("@ip_id", id);
SqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
comObj.ConferenceId = Convert.ToInt32(reader
["ConferenceId"].ToString());
comObj.Name = reader["Name"].ToString();
comObj.Team = reader["Team"].ToString();
comObj.EmpNo = Convert.ToInt32(reader["EmpNo"].ToString
());
comObj.ConferencePlace = Convert.ToInt32(reader
["ConferencePlace"].ToString());
comObj.FromTime = Convert.ToDateTime(reader
["FromTime"].ToString());
comObj.ToTime = Convert.ToDateTime(reader
["ToTime"].ToString());
comObj.TotalTime = reader["TotalTime"].ToString();
comObj.Status = reader["Status"].ToString();
comObj.OtherRequirements = reader
["Otherrequirements"].ToString();
comObj.Projector = reader["Projector"].ToString();
}
}
return comObj;
}
=============================
public DataTable GetSlotsPerEmployee(int empNo)
{
string conString = ConfigurationManager.AppSettings
["ConnectionString"];
using (SqlConnection con = new SqlConnection(conString))
{
if (con.State == ConnectionState.Closed)
con.Open();
SqlCommand command = new SqlCommand
("sp_GetSlotsPerEmployee", con);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.AddWithValue("@ip_EmpNo", empNo);
DataTable dataTable = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(command);
da.Fill(dataTable);
return dataTable;
}
}
=============================
On Dec 18, 9:54 am, nRk <[email protected]> wrote:
> Hi
> java is having something precompiled sql statments through connection
> objects. like
>
> [source java docs]
> PreparedStatement pstmt = con.prepareStatement("UPDATE EMPLOYEES SET
> SALARY = ? WHERE ID = ?");
> pstmt.setBigDecimal(1, 153833.00)
> pstmt.setInt(2, 110592)
>
> Does .net have anything like this in ado.net?
>
> thank
> nrk