create connetion with sql server

  • 10 years ago

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

  • 10 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

  • 10 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()

  • 10 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

  • 10 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.

“Beware of bugs in the above code; I have only proved it correct, not tried it.” - Donald Knuth