hello all

i am making a project and in that getting storing and loop problems

there are two fields serial no and quantity when quantity is entered serial number must be asked then only and the number of times quantity is entered that many times serial number must be asked also serial number is from to too

like 1 to 6 or 1 to 5 so i have to taken 2 textboxes serialfrm and serialto to store but now the problem is that i am not able to write proper code for it either it doesn't get saved to the particular name to which both fields belong or it keeps saving without stopping.

please HELP !!!

Are you using a database and if yes, which one? then also, how do you know which name to save it to?
Please explain further and show some code if possible

yes i am using SQL server 2005 database and i tried so many codes as follows : -

Dim constr As String
        'constr = System.Configuration.ConfigurationManager.AppSettings("ConnectionString")
        constr = "Data Source=.\SQLEXPRESS;AttachDbFilename=D:\Nazneen\Master\Master\Masterdb.mdf;Integrated Security=True;User Instance=True"
        Dim conn As New SqlConnection(constr)
        Try
            conn.Open()
            Dim query As String
            query = "select * from sales_mulkit_table"
            Dim da As New SqlDataAdapter(query, conn)
            Dim ds As Data.DataSet = New Data.DataSet("sales_mulkit_table")
            da.Fill(ds, "sales_mulkit_table")
            Dim table As New Data.DataTable
            table = ds.Tables("sales_mulkit_table")
            Dim newrow As Data.DataRow
            newrow = table.NewRow()
            newrow("dealer_code") = TextBox1.Text
            newrow("dealer_name") = TextBox2.Text
            newrow("quantity") = TextBox3.Text
            table.Rows.Add(newrow)
            Dim builder As New SqlCommandBuilder(da)
            da.InsertCommand = builder.GetInsertCommand()
            da.Update(ds, "sales_mulkit_table")
            ds.Clear()
            da.Fill(ds, "sales_mulkit_table")
            table = ds.Tables("sales_mulkit_table")
            MsgBox("Data Has Been Inserted Successfully In Database....")
        Catch ex As Exception
            MsgBox(ex.Message)
        Finally
            conn.Close()
        End Try

    End Sub

    Private Sub TextBox3_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox3.Enter

    End Sub

    Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged
        TextBox5.Enabled = True
        TextBox6.Enabled = True

        'Dim a As Integer
        Dim a As String

        'For Each a In Me.TextBox3.Text
        'If TextBox3.Text <= TextBox5.Text Or TextBox3.Text <= TextBox6.Text Then
        'For a = 1 To TextBox3.Text
        For Each a In Me.TextBox3.Text


            Dim constr As String
            'constr = System.Configuration.ConfigurationManager.AppSettings("ConnectionString")
            constr = "Data Source=.\SQLEXPRESS;AttachDbFilename=D:\Nazneen\Master\Master\Masterdb.mdf;Integrated Security=True;User Instance=True"
            Dim conn As New SqlConnection(constr)
            Try
                conn.Open()
                Dim query As String
                'Dim query1 As String
                query = "select serialfrm from sales_mulkit_table"
                'query1 = "select serialto from sales_mulkit_table"
                Dim da As New SqlDataAdapter(query, conn)
                Dim ds As Data.DataSet = New Data.DataSet("sales_mulkit_table")
                da.Fill(ds, "sales_mulkit_table")
                Dim table As New Data.DataTable
                table = ds.Tables("sales_mulkit_table")
                Dim newrow As Data.DataRow
                newrow = table.NewRow()
                newrow("serialfrm") = TextBox5.Text
                'newrow("serialto") = TextBox6.Text
                table.Rows.Add(newrow)
                Dim builder As New SqlCommandBuilder(da)
                da.InsertCommand = builder.GetInsertCommand()
                da.Update(ds, "sales_mulkit_table")
                ds.Clear()
                da.Fill(ds, "sales_mulkit_table")
                table = ds.Tables("sales_mulkit_table")

                MsgBox("Data Has Been Inserted Successfully In Database....")
            Catch ex As Exception
                MsgBox(ex.Message)
            Finally
                conn.Close()
            End Try

        Next
        'Else
        'TextBox3.Text <> TextBox5.Text And TextBox3.Text <> TextBox6.Text
        'MsgBox("Values Dont match with the quantity you entered")
        'End If
        'End If
        'Next

        'Me.Hide()
        'While TextBox3.Text <> ""
        'Dim a As New salesmulserialfrm
        'a.Show()

        'If TextBox3.Text >= TextBox4.Text And TextBox3.Text >= TextBox5.Text Then
        '    MsgBox("Invalid operation!!!")
        'End If
        '    If TextBox3.Text = Val(TextBox3.Text) Then
        '        Val(TextBox3.Text)

        '    End If
        'End While


    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.