create connetion with sql server

  • 14 years ago

    Hi. plz i need help how to create new connection with sql server from vb.net application.

  • 14 years ago

    Hi

    Dim ConnectionString As String="Server=ServerName;Uid=;pwd=;Data Source=DBName"
    Dim Connection As new SqlClient.SqlConnection
    Connection = New SqlClient.SqlConnection(ConnectionString)
    Connection.Open()


    Regards Raja.V

  • 14 years ago

    Dim ConnectionString As String="Server=ServerName;Uid=;pwd=;Data Source=DBName;initial catalog=DB Name Initial loaded"
    Dim Connection As new SqlClient.SqlConnection
    Connection = New SqlClient.SqlConnection(ConnectionString)
    Connection.Open()




    Do what u want to do

    .

    .

    .

    .

    .

     

    Connection.Close()

  • 14 years ago

    Hi I Got the same problem,  you can put this coding

    Dim connStr As String = "Server=localhost\SQLEXPRESS; Database=DatabaseName;" + " Integrated Security = SSPI"

    Thanks

  • 14 years ago

    Hi,

    In the Server put the name of the machine that you got SQL installed. Example: Server=MyPC\SQLEXPRESS;. Remove the localhost.

    And in the Database you have to put the database name: Example: Database=MyDB;. I doubt that your database name is "DatabaseName".

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“A computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are, in short, a perfect match” - Bill Bryson