Click here to Skip to main content
15,886,639 members

Comments by SAPTARSHI SENGUPTA (Top 11 by date)

SAPTARSHI SENGUPTA 1-Feb-16 15:00pm View    
yes because Some one is drop my table and delete data because my db user name pass is only known by me and i changed it regularly
SAPTARSHI SENGUPTA 1-Feb-16 14:58pm View    
My function is
private int ExecuteNonproc(string storedproc, string[] paraname, string[] paravalue)
{
try
{
int result = 0;
SqlConnection cn = new SqlConnection(cnn.DbConnectionString);
SqlCommand cmd = new SqlCommand(storedproc, cn);
cmd.CommandType = CommandType.StoredProcedure;
for (int i = 0; i < paraname.Length; i++)
{
cmd.Parameters.AddWithValue(paraname[i], paravalue[i]);
}
if (cn.State == ConnectionState.Open)
{
cn.Close();
}
cn.Open();
result = cmd.ExecuteNonQuery();
cn.Dispose();
cn.Close();
return result;
}
catch
{
throw;
}
}
and then
public int createAccount(AccountModel model)
{
try
{
string[] paraname = { "@Id", "@Name", "@Roll"};
string[] paravalue = { model.Id, model.Name, model.Roll };
return ExecuteNonproc("spp_add_student", paraname, paravalue);
}
catch
{

throw;
}
}
SAPTARSHI SENGUPTA 19-Aug-15 12:38pm View    
this is the sampel code first is the three function
SAPTARSHI SENGUPTA 19-Aug-15 12:37pm View    
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;
using Bioresonance.Models;


namespace Bioresonance.Class
{
public class adminDataLayer
{
connnection cnn = new connnection();
private DataSet Executeproc(string storedproc, string[] paraname,

string[] paravalue)
{
try
{
SqlDataAdapter da;
DataSet ds;
SqlConnection cn = new SqlConnection(cnn.DbConnectionString);
SqlCommand cmd = new SqlCommand(storedproc, cn);
cmd.CommandType = CommandType.StoredProcedure;
for (int i = 0; i < paraname.Length; i++)
{
cmd.Parameters.AddWithValue(paraname[i], paravalue[i]);
}
if (cn.State == ConnectionState.Open)
{
cn.Close();
}
da = new SqlDataAdapter(cmd);
ds = new DataSet();
da.Fill(ds);
cn.Dispose();
cn.Close();
return ds;
}
catch
{
throw;
}
}
private int ExecuteNonproc(string storedproc, string[] paraname,

string[] paravalue)
{
try
{
int result = 0;
SqlConnection cn = new SqlConnection(cnn.DbConnectionString);
SqlCommand cmd = new SqlCommand(storedproc, cn);
cmd.CommandType = CommandType.StoredProcedure;
for (int i = 0; i < paraname.Length; i++)
{
cmd.Parameters.AddWithValue(paraname[i], paravalue[i]);
}
if (cn.State == ConnectionState.Open)
{
cn.Close();
}
cn.Open();
result = cmd.ExecuteNonQuery();
cn.Dispose();
cn.Close();
return result;
}
catch
{
throw;
}
}

public DataSet Inline_Process(String Query)
{


SqlConnection con = new SqlConnection(cnn.DbConnectionString);
SqlCommand cmd = new SqlCommand(Query, con);


con.Open();
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
da.Dispose();
con.Dispose();
return ds;

}

public DataSet getlogin(AccountModel model)
{
try
{
string[] paraname = { "@User_Name", "@password" };
string[] paravalue = { model.username, model.password };
return Executeproc("spp_getLogin", paraname, paravalue);
}
catch
{

throw;
}
}
public DataSet changePassword(AccountModel model)
{
try
{
string[] paraname = { "@User_Name", "@OldPassword",

"@NewPass1", "@NewPass2" };
string[] paravalue = { model.username, model.OldPassword,

model.Password1, model.Password2 };
return Executeproc("spp_changePassword", paraname, paravalue);
}
catch
{

throw;
}
}
public int updateHeading(string HeadingFor, string Heading)
{
try
{
string[] paraname = { "@Heading_For", "@Heading" };
string[] paravalue = { HeadingFor, Heading };
return ExecuteNonproc("spp_updateHeading", paraname,

paravalue);
}
catch
{

throw;
}
}

public int updatePage(PageModel model)
{
try
{
SAPTARSHI SENGUPTA 19-Aug-15 12:37pm View    
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;
using Bioresonance.Models;


namespace Bioresonance.Class
{
public class adminDataLayer
{
connnection cnn = new connnection();
private DataSet Executeproc(string storedproc, string[] paraname,

string[] paravalue)
{
try
{
SqlDataAdapter da;
DataSet ds;
SqlConnection cn = new SqlConnection(cnn.DbConnectionString);
SqlCommand cmd = new SqlCommand(storedproc, cn);
cmd.CommandType = CommandType.StoredProcedure;
for (int i = 0; i < paraname.Length; i++)
{
cmd.Parameters.AddWithValue(paraname[i], paravalue[i]);
}
if (cn.State == ConnectionState.Open)
{
cn.Close();
}
da = new SqlDataAdapter(cmd);
ds = new DataSet();
da.Fill(ds);
cn.Dispose();
cn.Close();
return ds;
}
catch
{
throw;
}
}
private int ExecuteNonproc(string storedproc, string[] paraname,

string[] paravalue)
{
try
{
int result = 0;
SqlConnection cn = new SqlConnection(cnn.DbConnectionString);
SqlCommand cmd = new SqlCommand(storedproc, cn);
cmd.CommandType = CommandType.StoredProcedure;
for (int i = 0; i < paraname.Length; i++)
{
cmd.Parameters.AddWithValue(paraname[i], paravalue[i]);
}
if (cn.State == ConnectionState.Open)
{
cn.Close();
}
cn.Open();
result = cmd.ExecuteNonQuery();
cn.Dispose();
cn.Close();
return result;
}
catch
{
throw;
}
}

public DataSet Inline_Process(String Query)
{


SqlConnection con = new SqlConnection(cnn.DbConnectionString);
SqlCommand cmd = new SqlCommand(Query, con);


con.Open();
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
da.Dispose();
con.Dispose();
return ds;

}

public DataSet getlogin(AccountModel model)
{
try
{
string[] paraname = { "@User_Name", "@password" };
string[] paravalue = { model.username, model.password };
return Executeproc("spp_getLogin", paraname, paravalue);
}
catch
{

throw;
}
}
public DataSet changePassword(AccountModel model)
{
try
{
string[] paraname = { "@User_Name", "@OldPassword",

"@NewPass1", "@NewPass2" };
string[] paravalue = { model.username, model.OldPassword,

model.Password1, model.Password2 };
return Executeproc("spp_changePassword", paraname, paravalue);
}
catch
{

throw;
}
}
public int updateHeading(string HeadingFor, string Heading)
{
try
{
string[] paraname = { "@Heading_For", "@Heading" };
string[] paravalue = { HeadingFor, Heading };
return ExecuteNonproc("spp_updateHeading", paraname,

paravalue);
}
catch
{

throw;
}
}

public int updatePage(PageModel model)
{
try
{