473,394 Members | 1,932 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

duplicates? before inserting in dataset

Hello
I am trying to create a small application where the user must identify
before he begins. If it has never used the application, it identifies
creating a new user : firtsname + name + date of birth.
I created a form on which I drag and drop the table Eleves from my dataset
calcul_mentalDataSet from the database calcul_mental.mdb. As mentioned here:
http://plasserre.developpez.com/v6-6.htm in french....
I'd like to verify that the user does not exist prior to his registration.
Here is the current code:

Private Sub ElevesBindingNavigatorSaveItem_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
ElevesBindingNavigatorSaveItem.Click
Try
Me.ElevesBindingSource.EndEdit()
If Me.Validate Then
If VerifUserExist() = True Then 'Utilisateur déjà inscrit
MessageBox.Show("Utilisateur déjà inscrit", "ATTENTION
!", MessageBoxButtons.OK, MessageBoxIcon.Stop)
Else 'on met à jour la base
UpdateDatabase()
ModuleIdentite.MonNOM = NomTextBox.Text ' je mets
l'identité en mémoire dans le module accessible de partout
ModuleIdentite.MonPrenom = PrenomTextBox.Text
Frm_main_mdi.Text = "Bienvenue chez SC@LPA, " &
PrenomTextBox.Text & " !"
Frm_main_mdi.ActivitesToolStripMenuItem.Enabled = True
'l'élève est identifié alors il a accès au menu
Me.Close()
End If

End If
Catch ex As Exception
MessageBox.Show(ex.Message, "Inscription", MessageBoxButtons.OK,
MessageBoxIcon.Stop)
End Try

End Sub
''' <summary>
''' Update changes in Students table to database
''' </summary>
Private Sub UpdateDatabase()
Try
Me.ElevesTableAdapter.Update(Me.Calcul_mentalDataS et.Eleves)
Catch ex As Exception
MessageBox.Show(ex.Message, "Liste des éleves mise à jour",
MessageBoxButtons.OK, MessageBoxIcon.Stop)
End Try
End Sub

Function VerifUserExist() As Boolean
'Je récupère les infos entrées dans les différents textboxes
Dim strNom As String = NomTextBox.Text
Dim strPrenom As String = PrenomTextBox.Text
Dim dteDdn As String = DdnDateTimePicker.Value.ToString
'afin de les comparer à la table
Dim strSQL As String = "SELECT Nom, Prenom, Ddn FROM Eleves WHERE
Nom ='strNom' and Prenom ='strPrenom' and Ddn =#dteDdn#"
'################################################# ######################
'# 'i don't have any idea on how to handle the comparaison between
things entered by user and the database
#
'################################################# ######################
If True Then
Return True
Else
Return False
End If

End Function

thanks for your help
pascal
--
http://www.scalpa.info
http://scalpa98.blogspot.com/
http://scalpa-production.blogspot.com/

Oct 15 '08 #1
1 1570
This is subject to sql injection:

Dim strSQL As String = "SELECT Nom, Prenom, Ddn FROM Eleves WHERE
Nom ='strNom' and Prenom ='strPrenom' and Ddn =#dteDdn#"

Go here:
http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!176.entry

and find the Access example (permutation) (since you mention a mdb file)
public virtual IDataReader
OrdersGetAllForSpecificCustomerReader(string customerId)
That shows how to use parameters into an Access database.
See
http://en.wikipedia.org/wiki/SQL_injection

"Pascal" <sc************@scalpa.infowrote in message
news:F6**********************************@microsof t.com...
Hello
I am trying to create a small application where the user must identify
before he begins. If it has never used the application, it identifies
creating a new user : firtsname + name + date of birth.
I created a form on which I drag and drop the table Eleves from my dataset
calcul_mentalDataSet from the database calcul_mental.mdb. As mentioned
here:
http://plasserre.developpez.com/v6-6.htm in french....
I'd like to verify that the user does not exist prior to his registration.
Here is the current code:

Private Sub ElevesBindingNavigatorSaveItem_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
ElevesBindingNavigatorSaveItem.Click
Try
Me.ElevesBindingSource.EndEdit()
If Me.Validate Then
If VerifUserExist() = True Then 'Utilisateur déjà inscrit
MessageBox.Show("Utilisateur déjà inscrit", "ATTENTION
!", MessageBoxButtons.OK, MessageBoxIcon.Stop)
Else 'on met à jour la base
UpdateDatabase()
ModuleIdentite.MonNOM = NomTextBox.Text ' je mets
l'identité en mémoire dans le module accessible de partout
ModuleIdentite.MonPrenom = PrenomTextBox.Text
Frm_main_mdi.Text = "Bienvenue chez SC@LPA, " &
PrenomTextBox.Text & " !"
Frm_main_mdi.ActivitesToolStripMenuItem.Enabled = True
'l'élève est identifié alors il a accès au menu
Me.Close()
End If

End If
Catch ex As Exception
MessageBox.Show(ex.Message, "Inscription",
MessageBoxButtons.OK,
MessageBoxIcon.Stop)
End Try

End Sub
''' <summary>
''' Update changes in Students table to database
''' </summary>
Private Sub UpdateDatabase()
Try
Me.ElevesTableAdapter.Update(Me.Calcul_mentalDataS et.Eleves)
Catch ex As Exception
MessageBox.Show(ex.Message, "Liste des éleves mise à jour",
MessageBoxButtons.OK, MessageBoxIcon.Stop)
End Try
End Sub

Function VerifUserExist() As Boolean
'Je récupère les infos entrées dans les différents textboxes
Dim strNom As String = NomTextBox.Text
Dim strPrenom As String = PrenomTextBox.Text
Dim dteDdn As String = DdnDateTimePicker.Value.ToString
'afin de les comparer à la table
Dim strSQL As String = "SELECT Nom, Prenom, Ddn FROM Eleves WHERE
Nom ='strNom' and Prenom ='strPrenom' and Ddn =#dteDdn#"
'################################################# ######################
'# 'i don't have any idea on how to handle the comparaison between
things entered by user and the database
#
'################################################# ######################
If True Then
Return True
Else
Return False
End If

End Function

thanks for your help
pascal
--
http://www.scalpa.info
http://scalpa98.blogspot.com/
http://scalpa-production.blogspot.com/

Oct 15 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: bellefy | last post by:
Hi All, I have a fairly large table with approx 30K rows that updates every night via a cron script that automatically downloads the 2 new csv's. The problem is the files are downloaded from...
4
by: Drew | last post by:
I have a permission tracking app that I am working on, and I have made the insert page for it. I am having issues on how to prevent duplicates from getting entered. Currently the interface for...
2
by: a | last post by:
NEW Post Here's my best guess at how to insert this dataset.... the code runs, but no new records are added to the sql table. I've read and split a delimited text file into a dataset. It...
1
by: lanem | last post by:
I have a dataset that I've filled with the data I want. There are duplicate records in the dataset. Does anyone know a way to get rid of the duplicates? I'm sure I can do it with a bunch of code,...
2
by: Nathan | last post by:
Hi, I have a datagrid representing data in a dataset that is filled from an Access database table. Some of the columns in the table have been set not to allow duplicates. If I enter a...
0
by: toyin | last post by:
hello, pls help look through this code its not inserting the record in dataset into the another database. i want to insert the row in the dataset into another table in another database. pls help....
11
by: richardkreidl | last post by:
I'm trying to check for duplicates before I do an INSERT into the Access database table. I basically want to alert the user if the 'ProjectName' and the 'MileStones' are already in the table.. ...
4
by: apatel85 | last post by:
Hey Guys, Total Number of Records (Based on 5 fields): 1000 Total Unique Records (Based on 5 Fields): 990 Total number of fields: 5 I have question regarding extracting duplicates from the...
1
by: MattGaff | last post by:
I have a parameter (dropdown menu) on my report which will filter or sort the data depending on the chosen option. There are only 2 options to choose from in this dropdown. I want to Hide duplicates...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.