0

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
 
        Try
            cn.Open()
            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)

            cmd.ExecuteNonQuery()

            MessageBox.Show("Data Inserted")

        Catch ex As Exception
            MessageBox.Show(ex.ToString())

        Finally

            cn.Close()

        End Try
      End Sub
3
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by Netcode
0

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

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.