Working with the Wizard Control Using Visual Studio 2005
page 3 of 5
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 29764/ 82

Step 2 – Establishing a Database Connection Using SQL Server 2005 Express Edition

You will have to set up a database connection using Server Explorer; it is located at the left side of the IDE above the ToolBox panel, or it can be accessed using the View | Server Explorer menu.

1) Click on the Server Explorer panel, right-click on Data Connections, and select the Add Connection option.

2) In the window that pops up, select the Microsoft SQL Server Database file option and create a new database file called FormWizard_db.mdf.  Set your login credentials as appropriate for your server; the default is Windows Authentication.

3) At this stage you can select the default settings, and the database will be created for you by Visual Studio.

4) You will notice the database in the Server Explorer once it is created.

5) Click on the database name to expose the nodes underneath.  Right-click on the Tables node and add a new table with these columns:

   id - varchar(10)
   Fname - varchar(10)
   Lname - varchar(10)
   Email - varchar(50)
   Tel - varchar(20)

Choose to Save Table and name this new table Table1.

6) Add a stored procedure called dbo.StoredProcedure1 by right-clicking on the Stored Procedures node on the Server Explorer.  The code for this stored procedure can be found in Listing 1.

Listing 1 - Stored Procedure dbo.StoredProcedure1

CREATE PROCEDURE dbo.StoredProcedure1


  @Fname varchar(10),

  @Lname varchar(10),

  @Email varchar(50),

  @Tel varchar(20)


  INSERT INTO table1 (Fname, Lname, Email, Tel)

  VALUES (@Fname, @Lname, @Email, @Tel)


7) Create the connection string in the web.config file as shown in Listing 2.

Listing 2 - connectionStrings section of web.config

      <add name="dbConnectionString"
Security=True;Connect Timeout=30;User Instance=True"

Note: You should modify the path of the database file accordingly.

View Entire Article

User Comments

Title: nfl jerseys cheap   
Name: NIKE NFL jerseys
Date: 2012-07-02 10:11:56 AM
We are professional jerseys manufacturer from china, nike nfl jerseys, mlb jerseys, nhl jerseys,nba jerseys and shoes
,heap jerseys,2012 nike nfl Jerseys,nba jersey and shorts,oklahoma city thunder jersey,official jeremy lin new york knicks jersey,NFL Jerseys Wholesale,blake griffin jersey blue,NFL jerseys For Sale online.All Our Jerseys Are Sewn On and Directly From Chinese Jerseys Factory
,Wholesale cheap jerseys,Cheap mlb jerseys,]Nike NFL Jerseys,Cheap China Wholesae,Wholesale jerseys From China,2012 nike nfl Jerseys,Jerseys From China,,2012 nike nfl Jerseys,Revolution 30 nba jerseys,jersey of nba chicago bulls direk rose ,nfl jerseys,green bay packers jerseys wholesale,Buffalo Bills nike nfl jerseys sale,good supplier soccer jerseys,cool base mlb jerseys,Revolution 30 nba jerseys,2012 stanley cup nhl jersey,
We are professional jerseys manufacturer from china, nike nfl jerseys, mlb jerseys, nhl jerseys,nba jerseys and shoes.
Title: shubhjcjha   
Name: hghg
Date: 2012-06-29 2:05:43 AM
njn,h jhjch shd hdsh sac
Title: Solve My Problem - - - Keep it Up   
Name: Faheem Ahmad
Date: 2007-12-24 6:31:32 AM
It is an excellent article for beginners like me. Thanks aspalliance.
Title: Good   
Name: Althaf
Date: 2007-06-04 8:20:26 AM

Excellant assitance..

Keep going..
Title: Feedback 4 Wizard Control VS 2005   
Name: Mahesh Sharma
Date: 2007-05-30 2:21:21 PM
to all.
this is very nice article. i will get 100% assistence. and not need to look anywhere.
Title: Working with the Wizard Control Using Visual Studio 2005   
Name: Princess
Date: 2006-08-24 12:25:45 PM
Thank you..
Title: Perfect!   
Name: Tori Martinez
Date: 2006-05-21 12:15:12 PM
This is exactly what I was looking for. Thanks Eric!!!
Title: VB Code   
Name: Riceee
Date: 2006-05-16 6:07:22 AM
Heres the VB code for all of you that wanted it...

Public Sub insertDataIntoDB(ByVal fname As String, ByVal lname As String, ByVal email As String, ByVal tel As String)
Dim conn As String = System.Configuration.ConfigurationManager.ConnectionStrings("dbConnectionString").ConnectionString
Dim myConnection As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(conn)
Dim MySQL As String = "sp_results"
Dim cmd As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand(MySQL, myConnection)
cmd.CommandType = System.Data.CommandType.StoredProcedure
cmd.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Fname", fname))
cmd.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Lname", lname))
cmd.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Email", email))
cmd.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Tel", tel))

End Sub

Protected Sub Wizard1_FinishButtonClick(ByVal sender As Object, ByVal e As WizardNavigationEventArgs)
insertDataIntoDB(TextBox1.Text.ToString().Trim(), TextBox2.Text.ToString().Trim(), TextBox3.Text.ToString().Trim(), TextBox4.Text.ToString().Trim())
End Sub
Title: NIce Post   
Name: Rob
Date: 2006-05-10 2:27:25 PM
Nice Job! It was just what I was looking for (along time)! I was able to port the cs to vb with one of the many on-line cool tools.
Title: VB   
Name: Mystical
Date: 2006-05-05 5:32:50 AM

I need the code in VB too
Title: Working with the Wizard Control Using Visual Studio 2005   
Name: Shawn
Date: 2006-04-19 4:22:18 AM

Can I have the codes in VB.

Thank you

Community Advice: ASP | SQL | XML | Regular Expressions | Windows

©Copyright 1998-2021  |  Page Processed at 2021-12-05 6:48:05 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search