Posts tagged "Database"

Creating Sql Database Connection in Asp.net Web Application Through C#


1: Open visual studio 2005 and from FILE select NEW-> WebSite, then from pop-menu select asp.net website (Note: Language must be C#) , then press OK.

 

2: Now create three textboxes from the toolbox , to remove ambiguity I am using default name for that textboxes and that should be textbox1,textbox2 & textbox3. And also drag & drop the button to the asp.net application.

 

3: Meanwhile, Open SQL SERVER Management studio 2005 and open adventureworks(or you can create your own database by the Sql command CREATE DATABASE database_name), but here I am using AdventureWorks database.

 

4: Then create table by clicking right mouse button and form three column, Name them according to your requirement , for your information only I used EID,name,Address. And click save button, then you’ll get a pop up menu where you have to enter the Table Name, for this example I used  students.

 

5: Now Come Back to Visual studio Application and write the following code in the button_click event

 

protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection myConn = new SqlConnection();
myConn.ConnectionString = “Connection string(See Below for this —
)COPY PASTE  HERE“;

myConn.Open();
string strqry = “Insert into students values (” + TextBox1.Text +
“,’” + TextBox2.Text + “‘,’” + TextBox3.Text + “‘)”;

SqlCommand myCom = new SqlCommand(strqry, myConn);
int numrow = myCom.ExecuteNonQuery();
myConn.Close();

}

Kindly note down the connectionString Syntax, to obtain this string do the following steps :
Step 1 : Go to toolbox and from data section drag & drop SqlDataSource.
Step 2: Then on left clicking the mouse on SqlDataSource , you will get configureDataSource link, Slect this.
Step 3: NewConnection String -> Provide Server Name then select or write database name , i.e. AdventureWorks.
Step 4: TestConnection and then Press OK.
Step 5 : Now you will again redirect to the page that you actually see in the step 2, but this time click + sign before the connection string and from the drop drown hierarchy you will receive the connection string.
Step 6: Just copy and paste this string to the place of connectionstring.
Now debug & run Your application and check it’s effect on the table.
If still you face any problem feel free to ask.
Hope this explanation help you to understand the basics of database connectivity.
If you like this please comment it !
Thanks,
Anuj

Anuj Tripathi
Success comes to those who dares


I am a Computer Engineer, right now I am working as a software Engineer


Article from articlesbase.com



Be the first to comment - What do you think?
Posted by Anand Narayanaswamy - March 10, 2011 at 12:04 am

Categories: ASP.NET   Tags: application, ASP.NET, Connection, Creating, Database, Through

How to Keep Linq to Sql Classes in Sync With Database Structure

About Linq To Sql

Since it became available developers using .Net have no need to mix code with SQL commands within the application to access database objects. Now developers can access data in databases using programming language they get used to (C#, VB.NET). Moreover, using LINQ To SQL allows developer to uniformly manage all iterative data sources: databases, XML, various collections, etc. In addition you get code verification during compilation, full integration in Visual Studio which provides many advantages: IntelliSense, database model designer, auto generation of code by the model and so on.

Nothing is ideal

And still in spite of all advantages of using LINQ To SQL, its usage in real large projects is complicated for some problems. Using LINQ To SQL in the project will make you use such Visual Studio component as LINQ To SQL Classes. The component is not easy to use as it should be kept in sync with the structure of real database.

The variant of synchronizing LINQ To SQL Classes and database structure in manual mode is not considered at all due to huge work content and possibility of errors. Nevertheless, it is very important to keep LINQ To SQL Classes in sync with database structure, as LINQ To SQL Classes and database structure are often modified during software design.

Database Restyle – Library will solve the problem of the modifications transference from LINQ To SQL Classes to database structure.

In order to solve the first problem mentioned in the previous chapter, Perpetuum Software LLC developed the PerpetuumSoft.DataModel.LinqToSql library. This library allows the propagation of changes from LINQ To SQL to database structure without database re-creation. This library is based on another more functional Database Restyle library designed to synchronize two databases. Thus, you will have an opportunity to extend the standard abilities of the LINQ to SQL technology and avoid problems with synchronization of LINQ To SQL Classes with database structure.

The full article is available:

http://www.perpetuumsoft.com/Product.aspx?lang=en&pid=55&tid=linqtosqlsynchronization&dbrl

Perpetuum Software LLC specializes in development of high-quality .NET and ASP.NET software components compatible with MS Visual Studio .NET, C# Builder, Delphi .NET and other IDEs supporting .NET Framework. Such use-proven components as Report Sharp-Shooter, Instrumentation ModelKit, OLAP ModelKit, Chart ModelKit, the .NET Dashboard Suite, OLAP + CHART ModelKit and other .NET components by Perpetuum Software LLC are already well known on the software development market and are used by developers in more than 60 countries.


Article from articlesbase.com

Find More LINQ Articles

Be the first to comment - What do you think?
Posted by Anand Narayanaswamy - November 23, 2010 at 12:04 pm

Categories: linq   Tags: Classes, Database, Keep, linq, Structure, Sync

Migrating A SQL Server Database To SQL Azure

Migrating A SQL Server Database To SQL Azure2 Comments

SQL Azure is essentially a cut down version of SQL Server and so we would expect that migrating from SQL Server to SQL Azure should be a straightforward task. However, in the first release of SQL Azure, the scripts generated by SQL Server Management Studio will require some extra cleanup since not all the SQL Server 2008 features are supported in SQL Azure.

For this demo we will use SQL Server Management Studio (SSMS) to generate the SQL scripts and
migrate an existing database from SQL Server 2008 to  SQL Azure. It should be noted that there are several tools such as the SQL Migration Wizard for assisting in the migration, but in this article we will look at performing a manual migration.

Since SQL Azure is built from SQL Server 2008, the database should first be migrated to SQL Serer 2008 if necessary (note – it is not necessary to update to 2008 R2).

Open SQL Server Management Studio (SSMS), right-click on the database node of the database to be migrated (AdventureWorks for this demo) and select Tasks > Generate Scripts , then select the database to be migrated and click Next:

View the Original article

Be the first to comment - What do you think?
Posted by Anand Narayanaswamy - April 14, 2010 at 12:46 am

Categories: C#   Tags: Azure, Database, Migrating, Server

Restoring a database backup in .BAK format using SQL Server 2005

In most cases, you will be able to properly restore a SQL Server backup file in .BAK format using SQL Server 2005. But sometimes you will encounter the following error

Restore failed for Server ‘YOUR_COMPUTER_NAME’.  (Microsoft.SqlServer.Smo)

System.Data.SqlClient.SqlError: Directory lookup for the file "DRIVE:\SQL 2005\MSSQL.1\MSSQL\DATA\<<YOUR_DATABASE_NAME.mdf>>" failed with the operating system error 3(The system cannot find the path specified.). (Microsoft.SqlServer.Smo)

Follow the steps mentioned below to resolve the above mentioned error.

(1) Right click Databases tree and select Restore Database

(2) Enter a database name in "To database" field

(3) Select From Device option and click the Ellipse. Click Add button and select the database file name in .BAK format

(4) Check mark the checkbox below the Restore column

(5) Select Options section and you will find two colums titled "Original File Name" and "Restore As".

(6) The error can be fixed by changing the Restore As path for both data and log file. The correct path should be

C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\<<DATABASE_NAME>>.mdf
C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\<<DATABASE_NAME>>.ldf

(7) You will now be able to restore the backup without any problem.

NOTE: You need to follow the steps 5, 6 and 7 only if you encounter the above mentioned error. Otherwise, you can finish the task in Step 4 itself.

sql server, sql server 2005, database, backup, restore

3 comments - What do you think?
Posted by Anand Narayanaswamy - October 10, 2009 at 1:23 am

Categories: Channels, Database   Tags: .tif silverlight visual basic, backup, briefly about c# and c# tools, c sharp compiler download, c# compilers, C# keywords classified, csharp whiteboard, Database, develop in c# in windows98, download C# compiler for windows xp, download different Types Of Compilers in C#, explain briefly about c# and c# tools, google scada imaging, multiform application in C#.Net, restore, sample DragLeave in c#, silverlight shared whiteboard, sql server, sql server 2005, toolbar of crystal report on vs 2010

Building Data Aware Web Applications with ASP.NET

Nowadays, nearly every web site provides a facility for its users to register on the site. Sometimes, it may be compulsory to register on a site to avail certain services. For instance, imagine you are developing an e-commerce shopping store where your users should create a user id and password to login and begin shopping on that site.

Read more…

1 comment - What do you think?
Posted by Anand Narayanaswamy - January 18, 2009 at 7:50 am

Categories: Programming   Tags: ado.net, asp .net map scada open source, asp whiteboard plugin, ASP.NET, asp.net mvc scada, asp.net mvc2 chart, asp.net mvc2 charts, asp.net mvc2 google maps, asp.net mvc2 maintaining state, asp.net mvc2 reports, asp.net mvc2 webcontrol, briefly about c# and c# tools, c sharp compiler download, c# compilers, C# keywords classified, changing the position through coding in asp.net3.5, chart control 2010 express, chartcontrol mvc2, code to integrate facebook into ASP.Net, create asp.net mvc2 application, Database, develop in c# in windows98, display twitter timeline using twitterizer in asp.net, does nerddinner use oauth?, download C# compiler for windows xp, download different Types Of Compilers in C#, explain briefly about c# and c# tools, googlemap using asp.net mvc2, how do i refresh a chart using javascript in asp.net3.5, how to get refreshed data in charts in asp.net3.5, how to integrate webcontrols into mvc, how to put a chart control in mvc2 application, image map control in asp.net3.5, integrate facebook with asp.net3.5 example, Integrating facebook into ASP .net MVC using oAuth, intergate chart with dot net, multiform application in C#.Net, MVC2 htmlAttributes, mvc2 htmlattributes visible, nerddinner googlemaps, nerddinner map drag and drop, nerddinner twitter oauth, Twitterizer async example, visual studio 2010 pie chart control MVC, whiteboard plugin asp.net, working with chart control in asp.net3.5

Learn how to work with Java Database Connectivity

Assume that ABC Ltd is an automobile sales part manufacturing company that has many branches across the world. The corporate office at New York maintains MSAccess database for the sales details of various products, stock with each branch, personnel details etc.

Read more…

Be the first to comment - What do you think?
Posted by Anand Narayanaswamy - January 16, 2009 at 1:36 am

Categories: Programming   Tags: briefly about c# and c# tools, c sharp compiler download, c# compilers, C# keywords classified, Database, develop in c# in windows98, download C# compiler for windows xp, download different Types Of Compilers in C#, explain briefly about c# and c# tools, Java, JDBC, multiform application in C#.Net