I want to do a C# SQL class that help me to don't use Sqlconnections and ... many times in my programs
Now I have below code:
I have problem with data reader and adding parameters:
Help me to do it:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
/// <summary>
/// Summary description for mssql
/// Here I code a class to do my MS SQL jobs
/// With This class I don't need to use hard coding for each Query!
/// </summary>
public class mssql
{
public SqlConnection SQLConnection;
public SqlCommand SQLCommand;
//Do a constructor with open connection (Input Connection String)
public mssql(string cstr)
{
SQLConnection = new SqlConnection(cstr);
SQLConnection.Open();
}
//Make easy adding new paramter to str
public void addParam()
{
}
//exQuery just run Query and return last record ID
public void exQuery(string str)
{
SQLCommand = new SqlCommand(str, SQLConnection);
SQLCommand.ExecuteNonQuery();
}
//Data Reader to read str as Query
public
~mssql()
{
SQLConnection.Close();
}
}
In exQuery I need to add parameter I want to add parameters just by calling exQuery(Query,Array of params name,Array of Values)for data reader I want to give a query and output as array!


Sign In
Create Account


Back to top










