i have a problem when there is no data entered in the database and the data is entered for the first time. then it is giving an error even though the data is get saved. here is the code :

Protected Sub submit1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles submit1.Click
       Dim connstr As String
        Dim gp_no, year, sno, equip_no, qty, total_packets As Integer
        Dim description, make As String
        connstr = ConfigurationManager.ConnectionStrings("gate").ConnectionString()
        Dim conn As New SqlConnection(connstr)
        Dim dt As Date
        dt = Date.Today
        gp_no = serial.Text
        years.Text = DateTime.Now.Year
        sno = slno.Text
        description = descp.Text
        make = making.Text
        equip_no = equipno.Text
        qty = quantity.Text
        total_packets = totalpackets.Text
        Dim insert As New SqlClient.SqlCommand("insert into gatein_item (gp_no,year,sno,description ,make ,equip_no ,qty ,total_packets) Values('" & gp_no & "' ," & dt.Year & ",'" & sno & "' ,'" & description & "', '" & make & "','" & equip_no & "','" & qty & "','" & total_packets & "')", conn)
        MsgBox("record saved")
        Dim dn As SqlDataAdapter
        dn = New SqlDataAdapter("select sno, description, make, equip_sno,qty,total_packets from gatein_item", conn)
        Dim ds As New DataSet()
        Dim dr As DataRow
        GridView1.DataSource = ds.Tables()
dr = ds.Tables(0).NewRow()
        dr(1) = slno.Text
        dr(2) = descp.Text
        dr(3) = making.Text
        dr(4) = equipno.Text
        dr(5) = quantity.Text
        dr(6) = totalpackets.Text
        Dim cb As SqlCommandBuilder
        cb = New SqlCommandBuilder(dn)
    End Sub

and the exception is pointing towards the highlited area

Fill() method?

 dr = ds.Tables(0).NewRow()


First u need to import the System.data.sqlclient namespace.

Write the follwing code in Form_Load

Dim cn as new SqlConnection("connectionstring")
Dim da as new SqlDataAdapter("select custname from customers where custname like 's%'", cn)
Dim ds as new DataSet