Click here to Skip to main content
15,890,043 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi, I have an SQL database called sample_DB and a table called sample_tab. the columns on the table are uID(int),Lname(varchar),Fname(varchar),Mname(varchar),Img(Image),bDate(date).


i have been able to load it to devexpress gridcontrol without a problem.

this is my code:

VB
  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



that's as far i as i can go as for loading the table values to the gridcontrol on devexpress. my problem now is how to update the database using datatable. sorry for my bad english. hope you can help me with my project. thanks in advance.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900