Command Objects
|
Returns
|
O/p Type
|
Used
|
||
1
|
Execute Non Query
|
No Of Rows Effected
|
int
|
Insert, Update
|
|
2
|
ExecuteReader
|
SqlDataReader
|
SqlDataReader
|
Fetch Data
|
|
3
|
ExecuteScalar
|
First Col of First Row
|
int, string
|
Count(*)
|
|
4
|
SqlDataReader
|
||||
Features
|
|||||
Forward Read-only
|
|||||
Initiate only using ExecuteReader()
|
|||||
5
|
Dataset
|
||||
The DataSet represents
a complete set of data independent of actual DataSource
|
|||||
Interaction with
existing data sources is controlled through the DataAdapter
|
Thursday, 13 June 2013
Quick Reference to ADO.Net
Thursday, 28 February 2013
SQL Server Data Types and Their .NET Framework Equivalents
SQLServer datatype CLRdatatype(SQLServer) CLRdatatype(.NET Framework)
varbinary SqlBytes, SqlBinary Byte[]
binary SqlBytes, SqlBinary Byte[]
varbinary(1), binary(1) SqlBytes, SqlBinary byte, Byte[]
image None None
varchar None None
char None None
nvarchar(1), nchar(1) SqlChars, SqlString Char, String, Char[]
nvarchar SqlChars, SqlString String, Char[]
nchar SqlChars, SqlString String, Char[]
text None None
ntext None None
uniqueidentifier SqlGuid Guid
rowversion None Byte[]
bit SqlBoolean Boolean
tinyint SqlByte Byte
smallint SqlInt16 Int16
int SqlInt32 Int32
bigint SqlInt64 Int64
smallmoney SqlMoney Decimal
money SqlMoney Decimal
numeric SqlDecimal Decimal
decimal SqlDecimal Decimal
real SqlSingle Single
float SqlDouble Double
smalldatetime SqlDateTime DateTime
datetime SqlDateTime DateTime
sql_variant None Object
User-defined type(UDT) None user-defined type
table None None
cursor None None
timestamp None None
xml SqlXml None
Monday, 19 November 2012
Get Assembly location of the DLL added to SQL Server
SELECT
assembly = a.name,
path = f.name
FROM sys.assemblies AS a
INNER JOIN sys.assembly_files AS f
ON a.assembly_id = f.assembly_id
WHERE a.is_user_defined = 1;
Thursday, 8 November 2012
Get GridView Column Headers and Appropriate Row Values in Asp.Net
Get Gridview column header(s) text and Specific Row's Values on Row Command in asp.net. Below Method takes GridView control, Command Source Within the Row(LinkButton, Button, ImageButton, etc..), no of Columns to skip in from Start Column and from End Column as Parameters and returns List<KeyValuePair<headerText,Values>> as output.
private void SetDeleteDetails(GridView pGV, object pCmdSource, int pStartSkipColCount=0, int pEndSkipColCount=0)
{
List<KeyValuePair<string, string>> lkvp = new List<KeyValuePair<string, string>>();
GridViewRow rw = (GridViewRow)((Control)pCmdSource).NamingContainer;
for (int i = pStartSkipColCount; i < pGV.Columns.Count - pEndSkipColCount; i++)
if (!string.IsNullOrEmpty(rw.Cells[i].Text))
lkvp.Add(new KeyValuePair<string, string>(pGV.Columns[i].HeaderText, rw.Cells[i].Text));
//Session["DeleteDetails"] = lkvp;
}
Labels:
.Net,
ASp.Net,
C#,
CommandArgument,
GridView,
GridViewRowCommand
Wednesday, 7 November 2012
Get Specific Property Name Using Expression
Hope the program explains all:
class Program
{
static void Main(string[] args)
{
SomeClass sc = new SomeClass();
Console.WriteLine(sc.p1.GetType());
//RemoteMgr.ExposeProperty(() => SomeClass.SomeProperty);
MemberInfo member = RemoteMgr.GetMemberInfo((SomeClass p) => p.SomeProperty);
Console.WriteLine(member.Name);
Console.ReadKey();
}
}
public class SomeClass
{
public string SomeProperty
{
get { return "Foo"; }
}
}
public class RemoteMgr
{
public static MemberInfo GetMemberInfo<T, U>(Expression<Func<T,U>> expression)
{
var member = expression.Body as MemberExpression;
if (member != null)
return member.Member;
throw new ArgumentException("Expression is not a member access", "expression");
}
}
Monday, 22 October 2012
Raising a Button Click Event Programmatically
You can use the following C# code raise the event:
((IPostBackEventHandler)Button1).RaisePostBackEvent(null);
This code will raise the button-click event for Button1 just as though the user clicked the button. Since we are passing a null as the EventArgs for the event, the registered methods must not attempt to do anything with it. Or, you could create an EventArgs object and pass it.
There is at least one other approach using reflection, but I think the technique above is the cleaner way to do this.
Labels:
.Net,
ASp.Net,
AutoPostBack,
C#,
Control Events,
Controls
Monday, 8 October 2012
Understanding ASP.NET View State
Introduction
Microsoft® ASP.NET view state, in a nutshell, is the technique used by an ASP.NET Web page to persist changes to the state of a Web Form across postbacks. In my experiences as a trainer and consultant, view state has caused the most confusion among ASP.NET developers. When creating custom server controls or doing more advanced page techniques, not having a solid grasp of what view state is and how it works can come back to bite you. Web designers who are focused on creating low-bandwidth, streamlined pages oftentimes find themselves frustrated with view state, as well. The view state of a page is, by default, placed in a hidden form field named
__VIEWSTATE
. This hidden form field can easily get very large, on the order of tens of kilobytes. Not only does the __VIEWSTATE
form field cause slower downloads, but, whenever the user posts back the Web page, the contents of this hidden form field must be posted back in the HTTP request, thereby lengthening the request time, as well.
This article aims to be an in-depth examination of the ASP.NET view state. We'll look at exactly what view state is storing, and how the view state is serialized to the hidden form field and deserialized back on postback. We'll also discuss techniques for reducing the bandwidth required by the view state.
Note This article is geared toward the ASP.NET page developer rather than the ASP.NET server control developer. This article therefore does not include a discussion on how a control developer would implement saving state. For an in-depth discussion on that issue, refer to the book Developing Microsoft ASP.NET Server Controls and Components.
Before we can dive into our examination of view state, it is important that we first take a quick moment to discuss the ASP.NET page life cycle. That is, what exactly happens when a request comes in from a browser for an ASP.NET Web page? We'll step through this process in the next section.
Subscribe to:
Posts (Atom)