Dim conn As New SqlClient.SqlConnection 'create for connection Dim cmd As SqlClient.SqlCommand 'holder for sql command Dim da As SqlDataAdapter Dim dt As DataTable Dim ds As DataSet Sub open_db() 'this is for opening connection to database Try With conn If .State = ConnectionState.Open Then .Close() .ConnectionString = "Server=PC1;uID=sa;Database=Sample_DB;PWD=1234" .Open() End With Catch ex As Exception MessageBox.Show(ex.Message, "Error Connecting To Database", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Sub Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load 'load codes below when form loads Call open_db() End Sub Private Sub SimpleButton1_Click(sender As Object, e As EventArgs) Handles SimpleButton1.Click cmd = New SqlCommand("select * from customer_tab", conn) da = New SqlDataAdapter(cmd) dt = New DataTable da.Fill(dt) Dim repository As RepositoryItemPictureEdit = New RepositoryItemPictureEdit() GridControl1.DataSource = dt GridView1.Columns(4).ColumnEdit = repository End Sub
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)