i m using following query for inserting data into my database...
everything is ok
but whenever i restart my form there is no data in my tables :(
do i need to use commit statement ??
if yes then how ?

Private Sub Button1_insert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1_insert.Click
            Dim query As String = "insert into Department_Master values('" + TextBox1_deptid.Text + "','" + TextBox2_deptname.Text + "','" + TextBox3_remarks.Text + "') "
            Dim cmd As New SqlCommand(query, cn)


            MessageBox.Show("Data Inserted")

        Catch ex As Exception



        End Try
      End Sub

Recommended Answers

All 4 Replies

To get data, you have to create a new command, using SELECT statement.

i am using data grid for retrieving data
cant i get the data on data grid without select statement ?

You need the select statement to retrieve data into a dataset and then the datagrid displays the data in your dataset.

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.