Help me with the code or tutorial on how to connect vb .net with sql. dbase. thank you

Recommended Answers

All 4 Replies

Import the SqlClient first.

Then Establish the connection by

Sqlconnection conn=new Sqlconnection();
SqlCommand cmd=new SqlCommand("Query",conn);
cmd.ExecuteNonQuery();

See this site....
There are all about connection string to databases..
Just looking what you needed there.

A simple Insert Statement Function made by me for another project.

Function Insert(ByRef Conn As OleDbConnection, ByRef connection_string As String, ByRef Transaction As OleDbTransaction, ByRef ConnCommand As OleDbCommand, ByRef CommandText As String)
        Dim da As New OleDbDataAdapter

        Conn = New OleDbConnection(connection_string)

        Conn.Open()

        Transaction = Conn.BeginTransaction

        ConnCommand.Connection = Conn
        ConnCommand.Transaction = Transaction


        ConnCommand.CommandText = CommandText

        Try
            da.InsertCommand = ConnCommand
            da.InsertCommand.ExecuteNonQuery()

            Transaction.Commit()

            MessageBox.Show("Saved succesfully", "Adding Data", MessageBoxButtons.OK, MessageBoxIcon.Information)

        Catch ex As Exception

            Transaction.Rollback()
            MessageBox.Show(ex.Message)


        End Try

        Conn.Close()
        ConnCommand.Dispose()
        da.Dispose()
        Transaction.Dispose()

        Return Nothing
    End Function

Hope i helped!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.