Click here to Skip to main content
15,921,452 members
Home / Discussions / Database
   

Database

 
GeneralRe: How to create DSN at RUN time Pin
RichardGrimmer17-Jun-04 22:27
RichardGrimmer17-Jun-04 22:27 
GeneralRe: How to create DSN at RUN time Pin
Anonymous19-Jun-04 1:43
Anonymous19-Jun-04 1:43 
Generalhelp needed to create table for MS Access Pin
FASTian16-Jun-04 22:06
FASTian16-Jun-04 22:06 
GeneralRe: help needed to create table for MS Access Pin
Hesham Amin16-Jun-04 22:21
Hesham Amin16-Jun-04 22:21 
GeneralRe: help needed to create table for MS Access Pin
FASTian17-Jun-04 21:03
FASTian17-Jun-04 21:03 
GeneralRe: help needed to create table for MS Access Pin
Hesham Amin17-Jun-04 22:21
Hesham Amin17-Jun-04 22:21 
GeneralRe: help needed to create table for MS Access Pin
FASTian18-Jun-04 3:02
FASTian18-Jun-04 3:02 
Generalauto number generated Pin
viviansm16-Jun-04 21:40
viviansm16-Jun-04 21:40 
Good day.
I am a beginner in VB.NET. I have a problem that I used (TheTable.Rows.Count + 1) to generate the no. for the customer ID. If I deleted some of the records and then add a new records, the customer ID will not correct. This is because I am using TheTable.Rows.Count + 1, what I can do to solve this problem?
How do check the last customerID in the Customer table in SQL server? can this solve my problem? I am using ADO.net.
The code i am writing is :


Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click

SqlDataAdapter1.Fill(Me.DataSet11, "Customer")
Dim TheTable As DataTable = Me.DataSet11.Tables(0)
Dim aRow As DataRow = TheTable.NewRow()
txtCustID.Text = TheTable.Rows.Count + 1
ClearForm()
txtCustName.Focus()
end sub

Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
Try
Dim TheTable As DataTable = Me.DataSet11.Tables(0)
Dim aRow As DataRow = TheTable.NewRow()
aRow("CustID") = TheTable.Rows.Count + 1
aRow("CustName") = txtCustName.Text
aRow("CustAdd") = txtAdd.Text
aRow("Postcode") = txtPostcode.Text
aRow("City") = txtCity.Text


TheTable.Rows.Add(aRow)
SqlDataAdapter1.Update(Me.DataSet11, "Customer")
txtCustID.Text = aRow("CustID")
MessageBox.Show("Customer Was Successfully Added ", "VIP", MessageBoxButtons.OK, MessageBoxIcon.Information)

txtCustID.Text = TheTable.Rows.Count + 1
ClearForm()
txtCustName.Focus()

Catch ex As Exception
MessageBox.Show(ex.Message.ToString())
End Try

End Sub


If anyone know how to solve this problem, please post.
Thanks in advance!

viv
GeneralRe: auto number generated Pin
Tarakeshwar Reddy16-Jun-04 22:57
professionalTarakeshwar Reddy16-Jun-04 22:57 
GeneralRe: auto number generated Pin
WoutL16-Jun-04 23:09
WoutL16-Jun-04 23:09 
GeneralRe: auto number generated Pin
VenkatFor.NET17-Jun-04 4:57
VenkatFor.NET17-Jun-04 4:57 
QuestionHow to use a DataSet on a form, in another form. Pin
Member 114126616-Jun-04 21:23
Member 114126616-Jun-04 21:23 
AnswerRe: How to use a DataSet on a form, in another form. Pin
Tarakeshwar Reddy16-Jun-04 23:01
professionalTarakeshwar Reddy16-Jun-04 23:01 
AnswerRe: How to use a DataSet on a form, in another form. Pin
VenkatFor.NET17-Jun-04 5:00
VenkatFor.NET17-Jun-04 5:00 
QuestionHow to Fetch records Between two Dates Pin
Zeeshan Bilal16-Jun-04 20:03
Zeeshan Bilal16-Jun-04 20:03 
AnswerRe: How to Fetch records Between two Dates Pin
Anonymous16-Jun-04 21:06
Anonymous16-Jun-04 21:06 
GeneralRe: How to Fetch records Between two Dates Pin
Zeeshan Bilal16-Jun-04 21:29
Zeeshan Bilal16-Jun-04 21:29 
GeneralRe: How to Fetch records Between two Dates Pin
EdbertP17-Jun-04 13:06
EdbertP17-Jun-04 13:06 
GeneralRe: How to Fetch records Between two Dates Pin
Zeeshan Bilal17-Jun-04 19:17
Zeeshan Bilal17-Jun-04 19:17 
GeneralRe: How to Fetch records Between two Dates Pin
Zeeshan Bilal17-Jun-04 19:25
Zeeshan Bilal17-Jun-04 19:25 
GeneralRe: How to Fetch records Between two Dates Pin
Zeeshan Bilal17-Jun-04 19:29
Zeeshan Bilal17-Jun-04 19:29 
QuestionHow to use msadox and msado15 dll together Pin
Kaustubh_deo16-Jun-04 20:00
Kaustubh_deo16-Jun-04 20:00 
AnswerRe: How to use msadox and msado15 dll together Pin
RichardGrimmer17-Jun-04 3:49
RichardGrimmer17-Jun-04 3:49 
Questionhow i can take the sum of times Pin
syed saba16-Jun-04 1:01
syed saba16-Jun-04 1:01 
AnswerRe: how i can take the sum of times Pin
WoutL16-Jun-04 3:39
WoutL16-Jun-04 3:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.