Thursday, August 24, 2006

Sql Server Escape Sequence

Some times we are required to put '(Quotation Mark) in our sql stored procedure query.But '(Quotation Mark) will use for operation in sql server stored procedure. You can use escape sequence here.
for example you want to put 'jalpesh' in stored procedure then you should give
print '''jalpesh'''
here first two quota ion mark counted as escape sequence and then the third ' are counted as character.
Share:
Thursday, August 10, 2006

Starting Point of auto number fields in Microsoft Access

Auto Number Field handy things in Microsoft access.It will
automatically increase the filed value as records are
inserted. Developer don't have to care for it. By default
auto number field start with the zero but sometimes we
required to start auto number with rather than zero.

We can do it by creating the append query. Following
are the procedure for creating our own starting point
in the Microsoft access.

-First copy the auto number field table with another
table name.

-Now change the auto number field to the number field
in the newly created make sure that long integer is there.

-Now insert a record with starting point in newly created
table. For example you want to start with 300 then
insert with 300.

-Create a query from query designer of access
select all the field of newly created table.

-Go to the query menu select append query and into
destination table give original table name.

-Append it

- Delete newly created table.

That's it. You have created your own starting point.
now auto number starts with 300.

Happy Programming...
Share:

Paging in Datalist or Repeater Control In ASP.NET

==============================================
HTML of Datalist
==============================================
<asp:datalist id="dsList" runat="server" width=100%>

<ItemTemplate>

<%#DataBinder.Eval(Container.DataItem, "ID").ToString()%>

<%#DataBinder.Eval(Container.DataItem, "Name").ToString()%>

</ItemTemplate>

</asp:datalist>



<table width="100%" border="0" align="Center">

<tr>

<td><asp:LinkButton id="lnkPrevious" runat="server">

</asp:LinkButton>

</td>

<td><asp:LinkButton id="lnkNext" runat="server">>

</asp:LinkButton>

</td>

</tr>

</table>
===============================================
Server Side Coding : VB.NET
===============================================

Dim Start As Integer
Dim dbCon As SqlConnection
Dim Adpt As SqlDataAdapter
Dim dtUser As DataSet

Private Sub Page_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load

If Not Page.IsPostBack Then
ViewState("Start") = 0
BindData()
End If


End Sub

Sub BindData()

dbCon = New SqlConnection("server=localhost;uid=sa;
pwd=;database=user")
Adpt = New SqlDataAdapter("Select * from user ", dbCon)
dtUser = New DataSet
Start = ViewState("Start")
ViewState("Size") = 14
Adpt.Fill(dtUser, Start, ViewState("Size"), "user")
dsList.DataSource = dtUser
dsList.DataBind()

End Sub



Private Sub lnkPrevious_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles lnkPrevious.Click

Start = ViewState("Start")- ViewState("Size")
ViewState("Start") = Start
If Start <= 0 Then ViewState("Start") = 0 End If BindData() End Sub Private Sub lnkNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lnkNext.Click Dim count As Integer = dsList.Items.Count Start = ViewState("Start") + ViewState("Size") ViewState("Start") = Start If count <>
=====================================================
Server Side Coding: c#
=====================================================
int Start ;
SqlConnection dbCon ;
SqlDataAdapter Adpt ;
DataSet dtUser ;
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack )
{
ViewState["Start"] = 0;
BindData();
}
}
void BindData()
{
dbCon = new SqlConnection("server=localhost;uid=sa;
pwd=;database=user");
Adpt = new SqlDataAdapter("Select * from user", dbCon);
dtUser = new DataSet();
Start = (int)ViewState["Start"];
ViewState["Size"] = 14;
Adpt.Fill(dtUser, Start,(int) ViewState["Size"], "user");
dsList.DataSource = dtUser;
dsList.DataBind();
}

private void lnkPrevious_Click(object sender, System.EventArgs e)
{
Start = (int) ViewState["Start"] -(int) ViewState["Size"];
ViewState["Start"] = Start;
if (Start <= 0 ) { ViewState["Start"] = 0; } BindData(); } private void lnkNext_Click(object sender, System.EventArgs e) { int count = dsList.Items.Count; Start = (int) ViewState["Start"]+(int) ViewState["Size"]; ViewState["Start"] = Start; if ( count < (int)ViewState["Size"] ) { ViewState["Start"] = (int)ViewState["Start"] - (int)ViewState["Size"]; } BindData(); }
Share:
Monday, August 7, 2006

Crystal Report : Add Comand:

Some times we need only a single field from a particular table while creating a report.Which sometimes has no relationship with others.To do this So many peoples are importing table and use a one field.

Crystal Reports 9.0 onwards give us a facility called command which return the fields as you have specified in the command query.

To do this go to the database expert and select add command this will open a query window there and put the simple query and it will return fields you have specified in the query analyser.

It's very simple.Happy Programming....
Share:
Thursday, August 3, 2006

Displaying Multiple record in a Row in ASP.NET:

Sometimes we need to display multiple records in a
row. For example we need to display image details and
image for a image viewer application.

For that we could not use datagrid. Because it cannot
display more than one record in a row.

The Asp.NET 1.1 and 2.0 provides other called datalist.
Which provides this functionality very easily.

It contains two properties called 'RepeatColumns'
and 'Repeat Direction'.

'Repeat Column'- Sets how much records we need to display
in a row.

'Repeat Direction' -Sets the repeat direction
i.e. Horizontal or Vertical.

With the help of this properties one can easily
display more than one record in one row.

For more details regarding the datalist please visit:
http://msdn.microsoft.com/
or
http://www.syncfusion.com/FAQ/aspnet/WEB_c14c.aspx#q300q

Happy Programming...
Share:
Tuesday, August 1, 2006

Use Component Class in Business Logic Class in C# or VB.NET:

You can get many advantage using a component class instead
of simple class.

Following are the some basic advantage that you can get using
component class.

- It implements System.Component namespace
- You can drag and drop any existing data access component.So
you have to right less code.
- You can drag and drop stored procedure and other sql server
object and .NET IDE will create sqlcommand and adapter and
command object directly.
- You can use typed dataset with the component class easily
without writing any code through wizards.
Share:

Insert NUll in value datatype like int,float in C#

Some times we need to make some data type to null. Like
in some cases like stored procedure in database.

We can do it in C# very easily. by just putting ?sign in'
the definition like below:

int? a;

that's it! you have created a value data type with null
database. If you don't supply a value to the int a then
it will remain null.

You can use this for any value data type like short,single,
double,long,decimal etc.

Happy Programming...
Share:
Wednesday, July 12, 2006

Refactor tool in visual studio 2005

Re factor tool in the visual studio 2005

Visual studion provides great tool for modifying or make it simple. The Refactor tool
provides great functionality like changing parameters sequence or rename parameters,
record parameters,extract methods.

All this things can be done within the minutes. For c# go to in your code right
click and you can choose one of option that you want to do with your code.

Refractor for Visual Basic 2005:
=======================
Refactor! for Visual Basic 2005 is a free plug-in from Developer Express Inc.,
in partnership with Microsoft, that enables Visual Basic developers to simplify
and re-structure source code inside of Visual Studio 2005, making it easier to
read and less costly to maintain. Refactor! supports more than 15 individual
refactoring features, including operations like Reorder Parameters, Extract Method,
Encapsulate Field and Create Overload.

Download from this url:
http://msdn.microsoft.com/vbasic/downloads/tools/refactor/

For more details please visit:
http://sa-action.spaces.msn.com
Share:

Custom Membership and Role Provider In ASP.NET

Put this into web.config file for removing default connection string

&lt;connectionStrings>

&lt;remove name="LocalSqlServer"/>

&lt;add name="xyzConnectionString"

connectionString="Data Source=vsdotnet;

Initial Catalog=xyz;User Id=sa;Password=sa;"

providerName="System.Data.SqlClient"/>

&lt;/connectionStrings>

Put this in web.config file for membership providers.


&lt;membership>

&lt;providers>

&lt;remove name="AspNetSqlMembershipProvider"/>

&lt;add connectionStringName="xyzConnectionString"

enablePasswordRetrieval="false"

enablePasswordReset="true"

requiresQuestionAndAnswer="true"

applicationName="/"

requiresUniqueEmail="false"

passwordFormat="Hashed"

maxInvalidPasswordAttempts="4"

minRequiredPasswordLength="7"

minRequiredNonalphanumericCharacters="1"

passwordAttemptWindow="10"

passwordStrengthRegularExpression=""

name="AspNetSqlMembershipProvider"

type="System.Web.Security.SqlMembershipProvider,

System.Web, Version=2.0.0.0, Culture=neutral,

PublicKeyToken=b03f5f7f11d50a3a"/>

&lt;/providers>

&lt;/membership>


put this into web.config files for role provider


&lt;roleManager enabled="true">

&lt;providers>

&lt;remove name="AspNetSqlRoleProvider"/>

&lt;add connectionStringName="xyzConnectionString"

applicationName="/" name="AspNetSqlRoleProvider"

type="System.Web.Security.SqlRoleProvider, System.Web,

Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>

&lt;remove name="AspNetWindowsTokenRoleProvider"/>

&lt;/providers>

&lt;/roleManager>

Share:
Tuesday, July 4, 2006

Ajax,Microsoft, Atlas Proejct,ASP.NET

AJAX = Asynchronous JavaScript And XML

This name has made boom in web application development.Every days it is getting more and more popular.Ajax is a not a new language or standard but it is a simply a technique to use existing standard and development technology in to better way for creating better,Faster and more interactive and reach user interface web applications like desktop application.

It technique for fetching the server data without page submit or refreshing the pages. It uses javascript,XML and browsers http request for that.

The Big Company like Google and Microsoft already moving towards that with Google Suggest,Google Earth and Microsoft's live.com and live mail beta.

AJAX and ASP.NET:
So, Microsoft has also provided a Ajax framework called "Atlas" to develop ajax enabled application with the Microsoft ASP.NET 2.0 plate form. It provides easy to develop Ajax functionlity with out writing such heavy java script and XML codes.You can make your existing application Ajax enabled within the few minutes with that framework.

For more details Please visit http://atlas.asp.net/


Happy Programming...
Share:
Saturday, July 1, 2006

what is serialization -deserialization

Serialization is the process of storing class object into the some other
state may be a file or file or something like else.

Object Serialization is the process of reducing the objects instance into
a format that can either be stored to disk or transported over a Network.

Later time the Object will changed into its original state with the
re server process of deserialization.

Microsoft.NET support both serialization and deserialization.

Happy Programming..
Share:

how to add web servicein C# application

You can easily add web service to the application by add reference in C#
In the solution explorer right click the project and click add reference and
select add web reference then
type the URL of the web service that you would like to add to the web application
for example:
now you just need to refer this service like this:
localhost.HelloWebServiceinC MyService = new localhost.HelloWebServiceinC();
and you can use all the web methods that are defined in the webservice
through your application
Share:

Support this blog-Buy me a coffee

Buy me a coffeeBuy me a coffee
Search This Blog
Subscribe to my blog

  

My Mvp Profile
Follow us on facebook
Blog Archive
Total Pageviews