Question : Using SQL commands in Visual Studio 2008 Pro (VB)

Hello!

I need to know how to connect to a database in Visual Studio 2008 Pro (VB specifically).  I have a database set up, so I'm looking for the connection string/commands.  Basically, I make a form, put a button on the form, and when someone clicks the button, the connection is made and then I can run my SQL commands.  Once a connection is made, I need to insert the contents of a CSV file into the database.  The CSV file will probably be in c:/data.csv.  I have MS SQL Server 2005 installed.

Thank you for any help you can provide.

Answer : Using SQL commands in Visual Studio 2008 Pro (VB)

Private Sub btnInsert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInsert.Click
        Dim cn As New SqlConnection("Data Source=Your server address;Initial Catalog=YourDatabase;User Id=YourUsername;Password=YourPassword;")
        Dim cmd As New SqlCommand("Your insert query", cn)
        cn.Open()
        cmd.ExecuteNonQuery()
        cn.Close()
    End Sub
Random Solutions  
 
programming4us programming4us