Sunday, January 24, 2010

Fill Dataset with StoredProcedure ASP.NET C#

GridView DataBind with Dataset

GridView Fill Dataset with StoredProcedure ASP.NET C#

===========================================================

DataSet MyQueryMethod(string sqlQueryString)

{

DataSet ds = new DataSet();

System.Data.SqlClient.

SqlConnection sqlConnection = new System.Data.SqlClient. SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString" ].ConnectionString);

System.Data.SqlClient.

SqlDataAdapter dataAdapter = new System.Data.SqlClient. SqlDataAdapter();

System.Data.SqlClient.

SqlCommand select = new System.Data.SqlClient. SqlCommand(sqlQueryString);

select.CommandType =

CommandType.StoredProcedure;

select.Connection = sqlConnection;

select.Parameters.Add(

"@startdate", SqlDbType.DateTime).Value = TextBox1.Text;

select.Parameters.AddWithValue(

"@enddate", SqlDbType.DateTime).Value = TextBox2.Text ;

dataAdapter.SelectCommand = select;

dataAdapter.Fill(ds);

return ds;

}


===========================================


on Load event for call the function


GridView1.DataSource = MyQueryMethod("BrowseUserCharge");

GridView1.DataBind();

Saturday, January 23, 2010

Handle Database Null Values in VB.NET/ASP.NET

Handle Database Null Values in VB.NET/ASP.NET


Public Function IsDBNull(ByVal dbvalue) As Boolean
Return dbvalue Is DBNull.Value
End Function

Public Function FixNull(ByVal dbvalue) As String
If dbvalue Is DBNull.Value Then
Return ""
Else
'NOTE: This will cast value to string if
'it isn't a string.

Return dbvalue.ToString
End If
End Function




happy programming
Asma Qureshi

Wednesday, January 13, 2010

ADO.NET Architecture


ADO.NET is a data access technology from Microsoft .Net Framework , which provides communication between relational and non-relational systems through a common set of components . ADO.NET was built for a disconnected architecture , so it enables truly disconnected data access and data manipulation through its Dataset Object, which is completely independent from the Data Source.
ado.net-architecture.JPG

The two key components of ADO.NET are Data Providers and DataSet . The .Net Framework includes mainly three Data Providers for ADO.NET. The Microsoft SQL Server , OLEDB and ODBC are the main Data Providers in the .Net Framework. In the following pages you can see each component of ADO.NET in details with source code.




The following diagrams show the basic ADO.NET component architecture. The diagram on the left shows the Data Provider classes:
Command, Connection, DataAdapter, and DataReader. These classes provide bridges between .NET applications and data sources. The diagram on the right shows the DataSet class hierarchy. These classes create the .NET application's representation of a set of data.


Wednesday, January 06, 2010

"Unable to start debugging on the web server. You do not have permission to debug the application. The URL for this project is in the Internet zone."


Unable to start debugging on the web server VS.NET 2003



You may receive the error "Error while trying to run project: Unable to start debugging on the web server.
You do not have permission to debug the application. The URL for this project is in the Internet zone.
Click Help for more information."


This is one of the various errors that appear when you are debugging and may haunt you until you
do the following fix:-


1. In the Internet Explorer, "Tools" Menu, select "Internet Options".

2. Switch to "Security" Tab.

3. Click on "Internet" (The Globe Icon. Its actually the default selected).

4. Click on "Custom Level" in the bottom.

5. Scroll down to find the "User Authentication" section.

6. Select "Automatic logon with current username and password".

7. Click "Ok" twice to exit.

This should solve the issue.

Please note that this resolution is specific only if you get the exact error message as
mentioned in the beginning of this article.
There are various reasons you get the "Unable to start debugging on the webserver".
For a complete list of solutions, please check
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vsdebug.asp


Cheers and Happy Programming !!!