Automatic generation of numbers
-
Dear Sir, i amworking on vb.net i have a textbox field in the form called CardId now what i want is to generate numbers automatically and in a sequence. Suppose, when i click on the ADD RECORD button to add a new record, the cardid should be automatically generated as 1. if the record is saved ,then the next time when i am trying to add another record the cardid should be 2. but if the first record having cardid 1 is not saved then the next time i am adding a record the card id should be 1. can u pl help me through code. Arun
-
Dear Sir, i amworking on vb.net i have a textbox field in the form called CardId now what i want is to generate numbers automatically and in a sequence. Suppose, when i click on the ADD RECORD button to add a new record, the cardid should be automatically generated as 1. if the record is saved ,then the next time when i am trying to add another record the cardid should be 2. but if the first record having cardid 1 is not saved then the next time i am adding a record the card id should be 1. can u pl help me through code. Arun
dear arun, You can refer the code below. Function GenerateCode() As String Dim MyCommand As SqlClient.SqlDataAdapter Dim Dsg As New Customer Dim LastRec As Integer Try MyCommand = New SqlClient.SqlDataAdapter("select * from Cusdetail order by 1 asc", Myconnection) MyCommand.Fill(Dsg, "Cusdetail") LastRec = Dsg.CusDetail.Count() If LastRec > 0 Then LastRec = LastRec - 1 TxtCusCode.Text = Ds.CusDetail(LastRec).CusCode + 1 Else TxtCusCode.Text = "100001" 'Code for first Customer End If Catch ex As Exception Label11.Text = ex.Message() End Try Myconnection.Close() End Function Thankx Murtuza Patel.
-
Dear Sir, i amworking on vb.net i have a textbox field in the form called CardId now what i want is to generate numbers automatically and in a sequence. Suppose, when i click on the ADD RECORD button to add a new record, the cardid should be automatically generated as 1. if the record is saved ,then the next time when i am trying to add another record the cardid should be 2. but if the first record having cardid 1 is not saved then the next time i am adding a record the card id should be 1. can u pl help me through code. Arun
-
Dear Sir, i amworking on vb.net i have a textbox field in the form called CardId now what i want is to generate numbers automatically and in a sequence. Suppose, when i click on the ADD RECORD button to add a new record, the cardid should be automatically generated as 1. if the record is saved ,then the next time when i am trying to add another record the cardid should be 2. but if the first record having cardid 1 is not saved then the next time i am adding a record the card id should be 1. can u pl help me through code. Arun
is it not easier to use Access for that sort of things?