[bold]hi
iam woriking on windows application
In this application iam using a datagridview .My problem is i have to add columns dynamically into the datagridview and at the same time i have to add these column names as fields int the database table and also save,modify data in that dynamically added columns, and also Retrieve the data from the database into dynamically added columns [/bold]

Any one gives the answer

thanks in advance

//place testboxes for entering data
//then a command buttton click event fiill the data through these test boxes,here one testbox for enter name 

datagrid1.testmatrix(rowindex,colindex)=txtname.text

//then in the form load event fill the table by a select query

private sub form_load
Dim conn As SqlConnection
        Dim cmd As New SqlCommand
        Dim da As New SqlDataAdapter
        Dim ds As New DataSet
        Dim dt As New DataTable
  conn = GetConnect()
conn.open{}
cmd = conn.CreateCommand
            cmd.CommandText = "SELECT * FROM tablename"
            da.SelectCommand = cmd
            da.Fill(ds, "tablename")
            dg.DataSource = ds
            dg.DataMember = "tablename"
end sub

//save 

private sub savebutton_click
 Dim cmd As New SqlCommand
        Dim da As New SqlDataAdapter
        Dim ds As New DataSet
        Dim dt As New DataTable
  conn = GetConnect()
conn.open{}
cmd = conn.CreateCommand
            cmd.CommandText = "update tablename  where  txtname=' " & trim(txtname.test) & " ' "
end sub

//modify

private sub modifybutton_click
 Dim cmd As New SqlCommand
        Dim da As New SqlDataAdapter
        Dim ds As New DataSet
        Dim dt As New DataTable
  conn = GetConnect()
conn.open{}
cmd = conn.CreateCommand
            cmd.CommandText = "update tablename  set  txtname=' " & trim(txtname.test) & " ' "
end sub
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.