Questions tagged [sqlhelper]

SqlHelper class is a utility class that can be used to execute commands in a SQL Server database.

Introduction
The SqlHelper class is a utility class that can be used to execute commands in a SQL Server database. We know ADO.Net methods like SqlConnection,SqlDatAdapter and SqlCommand. To use these methods users typically write repititive lines of code like connecting to a db, executing the queries and finally disconnection from the db, etc. SqlHelper Class helps to reduce the number of lines coded.

Namespace
Microsoft.ApplicationBlocks.Data

Methods
ExecuteDataSet
ExecuteNonQuery
ExecuteReader
ExecuteScalar
ExecuteXmlReader

Syntax
SqlHelper.ExecuteDataSet(SqlConnection connection,string spname,params object[] parameter)

Example

SqlHelper.ExecuteNonQuery(DataAccess.ConnectionString, CommandType.StoredProcedure, "InsertStudent", new SqlParameter ("@RollNo",rollNo), new SqlParameter("@Name",name),new SqlParameter ("@Class",class));

References
http://msdn.microsoft.com/en-us/library/cc467894.aspx
http://www.codeproject.com/Tips/555870/SQL-Helper-Class-Microsoft-NET-Utility

50 questions
0
votes
2 answers

What is going on in this ExecuteDataset method?

OK so I one page I find this line: objDsCourse = SqlHelper.ExecuteDataset(ConfigurationManager.ConnectionStrings("connstr").ConnectionString, CommandType.StoredProcedure, "Course_NewReportGet_Get_Sav", objPAra) And I copied it to another page to…
MetaGuru
  • 42,847
  • 67
  • 188
  • 294
0
votes
2 answers

Return a 0 if no rows are found in Microsoft SQL Server

I need your help with this query. My table CSO_EMP_ORG_DPM_VIE has a column with different keys. Column name is EXT_KEY. When I receive the same key number in EXT_KEY, I want the SQL code to count the duplicates using this query: select EXT_KEY from…
0
votes
1 answer

Singleton Data Access Object (Dao) & SQL Helper Instance, Is here any Performance drawback?

I need comments from Experts. I write my own SQL Helper Class to Communicate with DB. Why I use it as because I try to Encapsulate the Ado.Net logic. Try to set a common standard for my developer in terms of DAL coding. Flexible & Easy to…
0
votes
1 answer

SQLHelper.DB not passing parameters to stored procedure

This is a new issue of my previous question (C# Using Parameters in SqlHelper.DB). If I pass null as the parameters and set the command text to a parameterless stored procedure, it works fine. SQLHelper.DB is executing the stored procedure but I…
Jeremy Hodge
  • 612
  • 3
  • 14
0
votes
0 answers

C# Using Parameters in SqlHelper.DB

I installed SqlHelper.DB NuGet package (https://www.nuget.org/packages/SQLHelper.DB/) and I am having issues passing parameters to the AddQuery method. I am passing a List of SqlParameter to my function and I receive an error: 'Failed to convert…
Jeremy Hodge
  • 612
  • 3
  • 14
0
votes
1 answer

SQL tool to list the related tables to the parent table

Dears, Could you please help me to find a SQL tool that will show me the list of the tables that have relation with the parent table. Example: Select * from table_1 when I write join there will be listed tables that are related to the table_1…
0
votes
1 answer

Devexpress gridview problem

when i access on database before binding the gridview the gridview never binding again here some code: void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { date.Date = DateTime.Now; string mode =…
Henawey
  • 508
  • 1
  • 9
  • 18
0
votes
1 answer

how to access an Output parameter in the old SQLHelper.cs class?

i'm currently modifying a legacy application that uses the SqlHelper class in c#. how do you access the OUTPUT value using an executedatareader?
Martin Ongtangco
  • 22,657
  • 16
  • 58
  • 84
0
votes
1 answer

Select Into ##TempTable from C# DataTable

I have a DataTable varriable in C# and I want to insert it to a ##TempTable in SQL Directly. I dont want to do like insert into ##TempTable row by row. How can I do that ? Select Into ##TempTable from (C# DataTable) ? Or I m asking in a different…
Ali CAKIL
  • 383
  • 5
  • 21
0
votes
1 answer

Query Help to determine average price for products < 3

Hi I've been working on this query, and I can't quite figure out the where statement to show only the average price of products < 3 "List each Product Class, number of items in the class and the average Price (name this Avg_Price, Format $0.00) of…
0
votes
0 answers

How to use Sqldependency with SqlHelper class

I am used to working with the SqlHelper class and so would like to modify the existing code to make use of it. existing code public string GetData() { string message = string.Empty; string conStr =…
sukesh
  • 2,379
  • 12
  • 56
  • 111
0
votes
0 answers

sql helper class get module for the procedures that return multiple values

I've written a module in my sql helper class which returns DataSet from the stored procedure. // public class SqlHelper public DataSet ExecuteDataSet(string commandText, SqlParameter[] sqlParameter) { SqlCommand cmd = new…
user4221591
  • 2,084
  • 7
  • 34
  • 68
0
votes
0 answers

How to avoid duplicated sql connection code

So, I recently asked a question about a class called SQLHelper, that was designed to cut down duplicated code whenever you connect to a SQL server, create a stored procedure command, etc. Essentially, from this: string connectionString = (string)…
Soni
  • 19
  • 1
  • 10
0
votes
1 answer

Can't Import libraries for SQLhelper class

I'm trying to remove duplicate code to connect to SQL database, create stored procedure parameters, etc. I found that SQLHelper class requires Enterprise library. So as we use NuGet, I downloaded the package and referenced it in the project. I then…
Soni
  • 19
  • 1
  • 10
0
votes
2 answers

SqlHelper ExecuteDataSet with named parameters?

Currently I'm using SqlHelper.ExecuteDataSet(string storedProcedure, Object[] parameters); to retrieve data from the database. The issue resides in the fact that order matters. I recently abstracted some of the functionality that produces the…
Shelby115
  • 2,816
  • 3
  • 36
  • 52