hi sir i m kunal raj want to share my problem pls help me
my application is like this :
i have to search my data from database with some check box and text box when user select check box specific function go on and then when user enters some range of value in textbox then the result will shown in data grid view after that i can print it by selecting data
my vb.net code is as follow [sorry for my bad english]

Imports System.Data
Imports System.Data.SqlClient


Public Class XtraForm1

    Dim cmd As New SqlCommand
    Dim dr As SqlDataReader
    Dim adp As New SqlDataAdapter
    Dim ds As DataSet
    Dim d As String
    Private con As New SqlConnection("Data Source=KUNAL-PC;Initial Catalog=Document Index;Integrated Security=True")

    Public Sub shippingbill()
        Try
            con.Open()
            con = New SqlConnection("Data Source=KUNAL-PC;Initial Catalog=Document Index;Integrated Security=True")
            adp = New SqlDataAdapter("select File_Name, Type, Doc_SRL_No, Buyer, Invoice_No, Shipping_Bill_No from Data where Shipping_Bill_No between='" + TextBox1.Text + "' and '" + TextBox2.Text + "'", con)
            ds = New DataSet()
            'cmd.Connection = con
            'adp.SelectCommand = cmd
            'ds.Clear()
            adp.Fill(ds, "Data")

            DataGridView1.DataSource = ds.Tables("Data")

        Catch ex As SqlException
            con.Close()
            MessageBox.Show("Data doesnot exist", "Message From Document Index", MessageBoxButtons.OK, MessageBoxIcon.Information)
        Catch ex1 As InvalidOperationException
            MessageBox.Show("Error While retrieving data, Please Try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
        con.Close()
    End Sub
    Public Sub invoiceno()
        Try
            con.Open()
            con = New SqlConnection("Data Source=KUNAL-PC;Initial Catalog=Document Index;Integrated Security=True")
            adp = New SqlDataAdapter("select File_Name, Type, Doc_SRL_No, Buyer, Invoice_No, Shipping_Bill_No from Data where Invoice_No between='" + TextBox1.Text + "' and '" + TextBox2.Text + "'", con)
            ds = New DataSet()
            'cmd.Connection = con
            'adp.SelectCommand = cmd
            'ds.Clear()
            adp.Fill(ds, "Data")

            DataGridView1.DataSource = ds.Tables("Data").DefaultView

        Catch ex As SqlException
            con.Close()
            MessageBox.Show("Data doesnot exist", "Message From Document Index", MessageBoxButtons.OK, MessageBoxIcon.Information)
        Catch ex1 As InvalidOperationException
            MessageBox.Show("Error While retrieving data, Please Try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
        con.Close()
    End Sub
    Public Sub DocSrlNo()
        Try
            con.Open()
            con = New SqlConnection("Data Source=KUNAL-PC;Initial Catalog=Document Index;Integrated Security=True")
            adp = New SqlDataAdapter("select File_Name, Type, Doc_SRL_No, Buyer, Invoice_No, Shipping_Bill_No from Data where Doc_SRL_No between='" + TextBox1.Text + "' and '" + TextBox2.Text + "'", con)
            ds = New DataSet()
            'cmd.Connection = con
            'adp.SelectCommand = cmd
            'ds.Clear()
            adp.Fill(ds, "Data")

            DataGridView1.DataSource = ds.Tables("Data")

        Catch ex As SqlException
            con.Close()
            MessageBox.Show("Data doesnot exist", "Message From Document Index", MessageBoxButtons.OK, MessageBoxIcon.Information)
        Catch ex1 As InvalidOperationException
            MessageBox.Show("Error While retrieving data, Please Try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
        con.Close()
    End Sub
    Private Sub XtraForm1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If RadioButton1.Checked = True Then
            DocSrlNo()
        ElseIf RadioButton2.Checked = True Then
            invoiceno()
        ElseIf RadioButton3.Checked = True Then
            shippingbill()
        Else
            MessageBox.Show("Please Checked it out your one choice for retrieving data", "Document Index say......", MessageBoxButtons.OK, MessageBoxIcon.Information)
        End If
    End Sub

    Private Sub RadioButton7_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub RectangleShape1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RectangleShape1.Click

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        shippingbill()
        invoiceno()
        DocSrlNo()

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        TextBox1.Text = ""
        TextBox2.Text = ""
    End Sub
End Class

i m also pasting the demo picture also that it helps to u justifying that what i m want to say pls. help me it's my project pls.

What trouble are you having?
From what I did see you don't really understand database connections and dataAapters. You set the connection string at the start of your class and then, for some reason, after opening the connection decide to set the connection object again.
Which is doubly pointless because you are using a dataAdapter which opens and closes its own connections anyway.

it donot show me data in gridview via sql database so what r the errors pls solve it
when i press ok button after giving a range of value in textboxes it show only exception message that is data doesn't exists

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.