If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Connect SQl server using VB.Net

Hi,

Step1: Creating the Database Files

CREATE DATABASE permission defaults to members of the sysadmin and dbcreator fixed server roles.

Using Object Explorer, creating a new database requires only that the database name be entered in the new database form. We open the form by right-clicking the databases node under a server and selecting New database. On the ‘General’ page, type a name for the database in the Database Name box. Click Ok. A database with the name you entered will be created.

1. In the Object Explorer expand the Databases Node and select a database.
2. To create a New Table right click the Tables node and select New Table from the Menu. Access the Table designer.
3. Select the Properties Window option in the Menu.
4. Type Name as Customer and Schema as mySchema.
5. Rows in the Table view correspond to columns in the Table.
6. Columns include CustID, CustName, and City.
7. Column properties listed include Name, Data Type and Allow Nulls.
8. When you are finished creating the Table, save the table.

Step4: Connecting to a Database through a VB 2005 program

The first step to using ADO.NET is to connect to a datasource. Using the Connection object, we instruct ADO.NET the database to contact. The Connection object is the gateway to the database, and all the operations performed against the database must go through this gateway. Connection objects expose a number properties and methods to manipulate from within the code. To do that, type the Imports statement for the System.Data.SqlClient name at the top of the form module.

The connectionString property is a long string with several attributes separated by semicolons. In the above connectionString, server is the name of the SQL Server, or ‘Local’ if you are running SQL Server on the same machine. We can replace the ‘server’ with the word ‘Data Source’ and ‘database’ with ‘Initial Catalog’. Integrated Security is to specify that the connection should be secure. The possible values for Integrated Security are ‘true’, ‘yes’, and ‘sspi’, which specify a secure connection.