|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Configuration;
using System.Data.SqlClient;
/// <summary>
/// Summary description for Class1
/// </summary>
public class Class1
{
public Class1()
{
//
// TODO: Add constructor logic here
//
}
public static DataSet fillDataset(string sql)
{
SqlConnection Scon = new SqlConnection(ConfigurationManager.ConnectionStrings["CS"].ToString());
SqlCommand Scmd = new SqlCommand(sql, Scon);
Scmd.CommandType = CommandType.Text;
SqlDataAdapter adp = new SqlDataAdapter(Scmd);
DataSet ds = new DataSet();
try
{
if (Scon.State == ConnectionState.Closed)
{
Scon.Open();
adp.Fill(ds);
}
}
catch
{
}
finally
{
adp.Dispose();
if (Scon.State == ConnectionState.Open)
{
Scon.Close();
}
}
return ds;
}
public static int nonquery(string sql)
{
SqlConnection Scon = new SqlConnection(ConfigurationManager.ConnectionStrings["CS"].ToString());
SqlCommand Scmd = new SqlCommand(sql, Scon);
Scmd.CommandType = CommandType.Text;
int rowsaffected = 0;
try
{
if (Scon.State == ConnectionState.Closed)
{
Scon.Open();
rowsaffected = Scmd.ExecuteNonQuery();
}
}
catch
{
}
finally
{
}
return rowsaffected;
}
public static int nonquery1(string Id, string name)
{
SqlConnection Scon = new SqlConnection(ConfigurationManager.ConnectionStrings["CS"].ToString());
SqlCommand Scmd = new SqlCommand("spUpdate", Scon);
Scmd.CommandType = CommandType.StoredProcedure;
Scmd.Parameters.Add("@FName", SqlDbType.VarChar).Value = name;
Scmd.Parameters.Add("@ID", SqlDbType.BigInt).Value = long.Parse(Id);
int rowsaffected = 0;
try
{
if (Scon.State == ConnectionState.Closed)
{
Scon.Open();
rowsaffected = Scmd.ExecuteNonQuery();
}
}
catch
{
}
finally
{
}
return rowsaffected;
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.