M
muhammadanzar
Guest
hi
Private Sub autoinvoice()
ClearTbox()
Dim adapter As New SqlDataAdapter("SELECT TOP 1 dbo.sales.invoice FROM dbo.sales ORDER BY dbo.sales.Invoice DESC", connection)
Dim table As New DataTable()
adapter.Fill(table)
v_invoice = table(0)(0) + 1
TextBox1.Text = v_invoice
this code is used for auto invoice no. it work fine, but in each invoice, serial start from 1 the code for auto serial not work code is given below, serial is just like a counter.
Private Sub AutoSerial()
Using connection1 As New SqlConnection("Data Source=.\SQLExpress;Initial Catalog=k1;Integrated Security=True")
Using command1 As New SqlCommand("Select top 1 dbo.sales.serial From dbo.sales WHERE dbo.sales.invoice =@TextBox1 ORDER BY Serial DESC", connection1)
command1.Parameters.Add("@TextBox1", SqlDbType.Int).Value = TextBox1.Text
Using adapters As New SqlDataAdapter(command1)
Using tables As New DataTable
adapters.Fill(tables)
If tables(0)(0) <> "" Then
TextBox24.Text = tables(0)(0) + 1
Else
TextBox24.Text = 1
End If
End Using
End Using
End Using
End Using
End Sub
Sql command work fine in sql server but in vb no value assign to textbox24.text. it also include in form load event as well.
now tell me where i am wrong
MUHAMMAD ANZAR E-mail : muhammadanzar@hotmail.com Mobile # :0092-3215096959
Continue reading...
Private Sub autoinvoice()
ClearTbox()
Dim adapter As New SqlDataAdapter("SELECT TOP 1 dbo.sales.invoice FROM dbo.sales ORDER BY dbo.sales.Invoice DESC", connection)
Dim table As New DataTable()
adapter.Fill(table)
v_invoice = table(0)(0) + 1
TextBox1.Text = v_invoice
this code is used for auto invoice no. it work fine, but in each invoice, serial start from 1 the code for auto serial not work code is given below, serial is just like a counter.
Private Sub AutoSerial()
Using connection1 As New SqlConnection("Data Source=.\SQLExpress;Initial Catalog=k1;Integrated Security=True")
Using command1 As New SqlCommand("Select top 1 dbo.sales.serial From dbo.sales WHERE dbo.sales.invoice =@TextBox1 ORDER BY Serial DESC", connection1)
command1.Parameters.Add("@TextBox1", SqlDbType.Int).Value = TextBox1.Text
Using adapters As New SqlDataAdapter(command1)
Using tables As New DataTable
adapters.Fill(tables)
If tables(0)(0) <> "" Then
TextBox24.Text = tables(0)(0) + 1
Else
TextBox24.Text = 1
End If
End Using
End Using
End Using
End Using
End Sub
Sql command work fine in sql server but in vb no value assign to textbox24.text. it also include in form load event as well.
now tell me where i am wrong
MUHAMMAD ANZAR E-mail : muhammadanzar@hotmail.com Mobile # :0092-3215096959
Continue reading...