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
1
vote
1 answer

Microsft SQLHelper vs Dapper

I am new to C#, programming for less than a year. Until now I have been using the Micrsoft SQLHelper class. (copy of text header below) I recently came across Dapper. Question is, should I switch to using Dapper ? Although the SQLHelper class has…
1
vote
1 answer

Is this way sufficient to execute DataSet?

I query one of my table using Stored Procedure Here is an example of method I have. I would like to make sure it's the most sufficient way and in case of 10000 of requests it will not cause overheat and close connection properly. public DataSet…
Michael Born
  • 799
  • 3
  • 15
  • 28
1
vote
1 answer

Android Pre Populated Database - Adding New Pre Populated Rows After Publication

I'm having trouble with a pre Populated database in android. Not the usual problems though. I've got the database working just fine. My problem comes with adding new data after the app has been published. I spent a lot of time with onupgrade method…
xn1
  • 417
  • 4
  • 12
1
vote
3 answers

SqlHelper.ExecuteReader results varying and unexpected when certain number of records are returned

Note: You may not need to read the whole thing to know what's wrong... skip down to the part about the 3 scenarios if you'd like. Only read the begin if you'd like some background info on how I've tried implementing this and where the errors…
Matt
  • 5,547
  • 23
  • 82
  • 121
1
vote
1 answer

SqlBulkCopy with SqlHelper class

I've installed DataAccessApplicationBlock.msi and I got the Microsoft.ApplicationBlocks.Data.dll file into my bin folder. I found every other sqlhelper methods except ExecuteBulkCopy. How do I add ExecuteBulkCopy function to the SqlHelper class?
ACP
  • 34,682
  • 100
  • 231
  • 371
1
vote
2 answers

Java/Android SQL Helper Class Why drop the table when upgrading?

For the majority of the examples and tutorials I have seen it is always suggesting to execute SQL to Delete the table if it exists in the onUpgrade method. Why would you want to delete the table as this would remove all the data, would it not be…
Sambuxc
  • 425
  • 2
  • 11
  • 26
1
vote
1 answer

Sql helper class in asp.net

Why should we use sql helper class in our application.What difference between sql helper class and simple class.In which situation sql Helper should used.Please define structure of class.
Vishal Nagra
  • 113
  • 2
  • 3
  • 8
1
vote
3 answers

How to make value of a column name appear with single apostrophe in sql statement of sql helper inside asp. net

SQLHelper sqhlpr = new SQLHelper(); sqhlpr.SqlText = "Select StudentName from tblStudentInfo where class=" + NurseryButton.Text; DataTable dt = sqhlpr.getDataTable(false); This is my code.Now the result of sqhlpr.sqlText is select…
Pratik.S
  • 470
  • 10
  • 30
1
vote
1 answer

SQLHelper Class - ExecuteNonQuery Code Modification

I am just browsing the code in the SQLHelper Class V2 and I notice the following public static int ExecuteNonQuery(SqlTransaction transaction, CommandType commandType, string commandText, params SqlParameter[] commandParameters) { …
Saif Khan
  • 18,402
  • 29
  • 102
  • 147
0
votes
1 answer

DataAccessLayer.SqlHelper.Stored procedures. Output parameters

I have a database with stored procedure inside. I'm trying to execute procedure using SqlHelper. However I'm getting weird error. public override User Insert(User entity) { var param = new SqlParameter() { Direction =…
magic987
  • 25
  • 1
  • 6
0
votes
1 answer

Lag Based on Specified Order in SQL

Does anyone know of a way to LAG in a specified order? In the example below, I provide a table with my current output [Lag (Current)] and my desired output [Lag (Desired)] columns. I am interested in creating a lag for the event time based on event…
leaner007
  • 17
  • 5
0
votes
1 answer

Count Unique Values Throughout One Day For Nonconsecutive Student ID's

I am trying to figure out how to count all instances where a student is online without counting duplicate instances. For example, in the screenshot below, I want to see a column counting only instances where a student is logged in. So, if Student A…
leaner007
  • 17
  • 5
0
votes
2 answers

Updates values from column in SQL

Im trying to change the value from the Merchant_Category_Code column. I tried CASE Statement but didn't work. CASE WHEN MERCHANT_CATEGORY_CODE = 6051 THEN 'Quasi Cash–Merchant' WHEN MERCHANT_CATEGORY_CODE = 4829 THEN 'Wire Transfer Money…
Mr.B
  • 3
  • 3
0
votes
1 answer

SQL world table, need help to show continents with more than 10 countries

I am trying to learn sql and i have downloaded a world database. My problem is that i cannot find out how to pick the continents with more than 10 countries in them My database is: name: (alle countries in the world) continent: (Africa, Americas,…
oljo
  • 59
  • 4
0
votes
3 answers

Based on todays date, how to get the date of the penultimate working day?

I try to figure out, how I can get the penultimate workingday from todays date. In my query, I would like to add an where clause where a specific date is <= today´s date minus 2 working days. Like: SELECT SalesAmount ,SalesDate FROM…