Custom Search

Wednesday, May 7, 2008

Storing Connection Strings in the Web Configuration File

There are three reason for why storing connection strings is a bad idea.first, it is not good from perspective of security.in this case, no one should ever be able to view the source code of your ASP.NET pages, but in practice,hackers have discovered security flaws in the ASP.NET framework.so you should store your connection strings in a separate file.

second, adding a connection string to every page makes it difficult to manage a website,in other hand if you need change connection string, you only modifying the single file.

last, storing a connection string in a page can, potentially, hurt the performance of your application.

for these reason, you should always put your connection string in the web configuration file.

eXAMPLE

Web.Config

< ?xml version="1.0"?>
<>
<>
< name="student" connectionstring="Data Source=.\SQLEXPRESS; AttachDbFilename=|DataDirectory|MyData.mdf;Integrated Security=True; User Instance=True">
< /connectionStrings>
< /configuration>

displaystudent.aspx

< %@ Page Language="VB" %>
< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
< xmlns="http://www.w3.org/1999/xhtml">
< id="Head1" runat="server">
<>Show Movies
< /head>
< body>
< id="form1" runat="server">
< div>

< id="grdStudent" datasourceid="srcStudent" runat="server">

< id="srcStudent" selectcommand="SELECT * FROM student" connectionstring="<%$ ConnectionStrings:student %>">"
Runat="server" />

< /div>
< /form>
< /body>
< /html>

The expression <%$ ConnectionStrings:student %> is used to represent the connection string. This expression is not case sensitive.

Monday, May 5, 2008

SqlDataSource Overview

The SqlDataSource control enables you to quickly and easily represent a SQL database in a web page. In many cases, you can take advantage of the SqlDataSource control to write a database-driven web page without writing a single line of code.You use the SqlDataSource control to represent a connection and set of commands that can be executed against a SQL database. You can use the SqlDataSource control when working with Microsoft SQL Server, Microsoft SQL Server Express, Microsoft Access, Oracle, DB2, MySQL, or just about any other SQL relational database ever created by man.

How to creating Database Connection
By default, the SqlDataSource control is configured to connect to Microsoft SQL Server version 7.0 or higher. The default provider used by the SqlDataSource control is the ADO.NET provider for Microsoft SQL Server.
Example :
< %@ Page Language="VB" %>
< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
< xmlns="http://www.w3.org/1999/xhtml">
< id="Head1" runat="server">
<>Show Example Connection
< /head>
<>
< id="form1" runat="server">
<>

< id="grdTeacher" datasourceid="srcTeacher" runat="server">

< id="srcTeacher" selectcommand="SELECT * FROM Teacher" connectionstring="Data Source=.\SQLEXPRESS; AttachDbFilename=|DataDirectory|MyData.mdf; Integrated Security=True;User Instance=True" runat="server">

< /div>
< /form>

< /body>
< /html>

This connection string connects to an instance of SQL Server Express located on the local machine and a database file named MyData.mdf. The connection string uses Integrated Security (a Trusted Connection) to connect to the local database.

Saturday, May 3, 2008

More about AJAX

I found a website that contains more about AJAX. This include AJAX example, AJAX tools and many more, check in here




Free Traffic

 Join My Community at MyBloglog! Blog Flux Directory 

Web Developement Blogs - BlogCatalog Blog Directory web development blog  Internet Blogs - Blog Top Sites 

Blog Directory 

Click Here for Free Traffic!

Link2Communion.com