Accueil > > > GESTION BASE DE DONNÉES AVEC VB.NET
GESTION BASE DE DONNÉES AVEC VB.NET
Information sur la source
Description
dammak abdelfatteh cette interface permet la gestion d'une base de donnée sur sql server avec vb.net
Source
- Imports System.Data
- Imports System.Data.OleDb
- Imports System.Data.SqlClient
- Imports Microsoft.VisualBasic
- Imports System.Data.Sql
- Imports System.IO
- Public Class Form1
- Dim connexion As New SqlConnection
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- End Sub
- Public Sub connection()
-
- connexion.ConnectionString = "Data Source=localhost;Initial Catalog=base;Integrated Security=True"
- connexion.Open()
- If connexion.State = ConnectionState.Open Then
- MsgBox("Connexion reussite", MsgBoxStyle.Exclamation, "Status")
- Else
- MsgBox("Connexion non reussite", MsgBoxStyle.Critical, "Status")
- End If
- connexion.Close()
- End Sub
-
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- AjouterArticle()
- End Sub
- Public Sub AjouterArticle()
- Try
- connection()
- Dim strRequete As String = "SELECT * FROM Article "
- Dim dtt As DataTable
- Dim oSqlDataAdapter As New SqlDataAdapter(strRequete, connexion)
- Dim oDataSet As New DataSet("Article")
- oSqlDataAdapter.Fill(oDataSet, "Article")
- dtt = oDataSet.Tables("Article")
-
- oSqlDataAdapter.InsertCommand = New SqlCommand("INSERT INTO Article(COD_AR,NOM_AR,QTE_AR) Values(@COD_AR,@NOM_AR,@QTE_AR)", connexion)
- oSqlDataAdapter.InsertCommand.Parameters.Add("@COD_AR", SqlDbType.Int, 30, "COD_AR")
- oSqlDataAdapter.InsertCommand.Parameters.Add("@NOM_AR", SqlDbType.NChar, 15, "NOM_AR")
- oSqlDataAdapter.InsertCommand.Parameters.Add("@QTE_AR", SqlDbType.Int, 100, "QTE_AR")
-
- Dim oDataRow As DataRow
- Dim byteArray As Byte() = {}
-
-
- '''''''''''''''''''test des champs saisies''''''''''''''''
-
- '''''''''''''''''''fin test champs''''''''''''''''''''''''
- oDataRow = oDataSet.Tables("Article").NewRow()
- oDataRow("COD_AR") = code.Text
- oDataRow("NOM_AR") = nom.Text
- oDataRow("QTE_AR") = qte.Text
-
-
- oDataSet.Tables("Article").Rows.Add(oDataRow)
- oSqlDataAdapter.Update(oDataSet, "Article")
-
- 'on vide le dataset pour le recréer avec les nouvelles données
- oDataSet.Clear()
- oSqlDataAdapter.Fill(oDataSet, "Article")
- dtt = oDataSet.Tables("Article")
- MsgBox("Article enregistré avec succés", MsgBoxStyle.Information, "Status")
- connexion.Close()
- Catch
- MsgBox("Echec d'enregistrement")
- End Try
- End Sub
-
- Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
- nom.Visible = False
- qte.Visible = False
- Label2.Visible = False
- Label3.Visible = False
- Button1.Enabled = False
- Button2.Enabled = False
- Button4.Visible = True
- End Sub
- Public Sub supprimer()
- Try
- Dim req As String
- Dim query As SqlCommand
- connection()
-
- req = "delete from Article where COD_AR=" & code.Text & ""
- query = New SqlCommand(req)
- query.Connection = connexion
- If query.ExecuteNonQuery() Then
- MsgBox("L'article " & code.Text & "est supprimé avec succés", MsgBoxStyle.Information, "Status")
- Else
- MsgBox("Echec suppression de l'article " & code.Text & "", MsgBoxStyle.Critical, "Status")
- End If
- connexion.Close()
- Catch ex As Exception
- MsgBox("Erreur", MsgBoxStyle.Critical, "Status")
- End Try
- End Sub
-
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
- Try
- Dim req As String
- Dim query As SqlCommand
- connection()
-
-
- req = "update Personnel set NOM_AR='" & nom.Text & "', QTE_AR=" & qte.Text & " where COD_AR = " & code.Text & ""
- query = New SqlCommand(req)
- query.Connection = connexion
- If query.ExecuteNonQuery() Then
- MsgBox("L'article " & code.Text & " est modifié avec succés", MsgBoxStyle.Information, "Status")
- Else
- MsgBox("Echec modification de l'article " & code.Text & "", MsgBoxStyle.Critical, "Status")
-
- End If
-
- connexion.Close()
- Catch ex As Exception
- MsgBox("Erreur", MsgBoxStyle.Critical, "Status")
- End Try
- End Sub
-
- Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
- supprimer()
- End Sub
- End Class
Imports System.Data
Imports System.Data.OleDb
Imports System.Data.SqlClient
Imports Microsoft.VisualBasic
Imports System.Data.Sql
Imports System.IO
Public Class Form1
Dim connexion As New SqlConnection
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Public Sub connection()
connexion.ConnectionString = "Data Source=localhost;Initial Catalog=base;Integrated Security=True"
connexion.Open()
If connexion.State = ConnectionState.Open Then
MsgBox("Connexion reussite", MsgBoxStyle.Exclamation, "Status")
Else
MsgBox("Connexion non reussite", MsgBoxStyle.Critical, "Status")
End If
connexion.Close()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
AjouterArticle()
End Sub
Public Sub AjouterArticle()
Try
connection()
Dim strRequete As String = "SELECT * FROM Article "
Dim dtt As DataTable
Dim oSqlDataAdapter As New SqlDataAdapter(strRequete, connexion)
Dim oDataSet As New DataSet("Article")
oSqlDataAdapter.Fill(oDataSet, "Article")
dtt = oDataSet.Tables("Article")
oSqlDataAdapter.InsertCommand = New SqlCommand("INSERT INTO Article(COD_AR,NOM_AR,QTE_AR) Values(@COD_AR,@NOM_AR,@QTE_AR)", connexion)
oSqlDataAdapter.InsertCommand.Parameters.Add("@COD_AR", SqlDbType.Int, 30, "COD_AR")
oSqlDataAdapter.InsertCommand.Parameters.Add("@NOM_AR", SqlDbType.NChar, 15, "NOM_AR")
oSqlDataAdapter.InsertCommand.Parameters.Add("@QTE_AR", SqlDbType.Int, 100, "QTE_AR")
Dim oDataRow As DataRow
Dim byteArray As Byte() = {}
'''''''''''''''''''test des champs saisies''''''''''''''''
'''''''''''''''''''fin test champs''''''''''''''''''''''''
oDataRow = oDataSet.Tables("Article").NewRow()
oDataRow("COD_AR") = code.Text
oDataRow("NOM_AR") = nom.Text
oDataRow("QTE_AR") = qte.Text
oDataSet.Tables("Article").Rows.Add(oDataRow)
oSqlDataAdapter.Update(oDataSet, "Article")
'on vide le dataset pour le recréer avec les nouvelles données
oDataSet.Clear()
oSqlDataAdapter.Fill(oDataSet, "Article")
dtt = oDataSet.Tables("Article")
MsgBox("Article enregistré avec succés", MsgBoxStyle.Information, "Status")
connexion.Close()
Catch
MsgBox("Echec d'enregistrement")
End Try
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
nom.Visible = False
qte.Visible = False
Label2.Visible = False
Label3.Visible = False
Button1.Enabled = False
Button2.Enabled = False
Button4.Visible = True
End Sub
Public Sub supprimer()
Try
Dim req As String
Dim query As SqlCommand
connection()
req = "delete from Article where COD_AR=" & code.Text & ""
query = New SqlCommand(req)
query.Connection = connexion
If query.ExecuteNonQuery() Then
MsgBox("L'article " & code.Text & "est supprimé avec succés", MsgBoxStyle.Information, "Status")
Else
MsgBox("Echec suppression de l'article " & code.Text & "", MsgBoxStyle.Critical, "Status")
End If
connexion.Close()
Catch ex As Exception
MsgBox("Erreur", MsgBoxStyle.Critical, "Status")
End Try
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Try
Dim req As String
Dim query As SqlCommand
connection()
req = "update Personnel set NOM_AR='" & nom.Text & "', QTE_AR=" & qte.Text & " where COD_AR = " & code.Text & ""
query = New SqlCommand(req)
query.Connection = connexion
If query.ExecuteNonQuery() Then
MsgBox("L'article " & code.Text & " est modifié avec succés", MsgBoxStyle.Information, "Status")
Else
MsgBox("Echec modification de l'article " & code.Text & "", MsgBoxStyle.Critical, "Status")
End If
connexion.Close()
Catch ex As Exception
MsgBox("Erreur", MsgBoxStyle.Critical, "Status")
End Try
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
supprimer()
End Sub
End Class
Conclusion
dammak abdelfatteh ,merci
Historique
- 21 juillet 2008 13:32:58 :
- regulation de la connexion bd
- 21 juillet 2008 13:41:28 :
- bd ok
Sources de la même categorie
Commentaires et avis
|
Derniers Blogs
[WP7] DYNAMICALLY CHANGE STARTUP PAGE[WP7] DYNAMICALLY CHANGE STARTUP PAGE par KooKiz
Let's say that you want to allow the user to customize the startup page of your application. You can easily change the startup page by editing the 'NavigationPage' attribute in the manifest file. But the manifest cannot be modified once the applicatio...
Cliquez pour lire la suite de l'article par KooKiz SESSION SILVERLIGHT 5 3D : SLIDES ET DEMOSSESSION SILVERLIGHT 5 3D : SLIDES ET DEMOS par Groc
Durant les techdays, j'ai eu le plaisir d'animer une session sur Silverlight 5 et la 3D avec Simon Ferquel. Comme promis, voici nos slides et mes démos (celles avec le viper BSG) ici et là. Pour mémoire, les démos utilisent toutes le viper BSG...
Cliquez pour lire la suite de l'article par Groc [TECHDAYS 2012] SESSION WEBMATRIX 2 : LE COUTEAU SUISSE GRATUIT POUR VOS DéVELOPPEMENTS WEB - SLIDES[TECHDAYS 2012] SESSION WEBMATRIX 2 : LE COUTEAU SUISSE GRATUIT POUR VOS DéVELOPPEMENTS WEB - SLIDES par gpommier
Suite à la session que j'ai présenté sur WebMatrix 2, vous pouvez trouver les slides ici, ainsi que les démos en packages nuget : démos1 et démos2 J'en profite pour remercier chaleureusement tous ceux qui sont venus très nombreux à cette sess...
Cliquez pour lire la suite de l'article par gpommier [SHAREPOINT] LES SESSIONS TECHDAYS 2012.[SHAREPOINT] LES SESSIONS TECHDAYS 2012. par Patrick Guimonet
Voici donc pour ceux qui n'ont pas pu venir, ou ceux qui n'ont pas pu toutes les suivre la liste des sessions SharePoint aux TechDays 2012, que je mettrais à jour dès que les liens des vidéo seront disponibles. Ou ici : http...
Cliquez pour lire la suite de l'article par Patrick Guimonet TECHDAYS PARIS 2012 : SESSION PLEINIèRE JOUR 3TECHDAYS PARIS 2012 : SESSION PLEINIèRE JOUR 3 par ROMELARD Fabrice
Speaker: Bernard Ourghanlian Cette session est comme chaque jour transmise en live par BrainSonic, et j'ai donc suivi cette troisième pleinière par ce moyen sur mon iPad . Elle est dédiée comme chaque année à la mise en perspective de l'é...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice
Forum
LISTER KEYS.KEYLISTER KEYS.KEY par Onin42
Cliquez pour lire la suite par Onin42
Logiciels
Tribler (2012)TRIBLER (2012)Tribler est un client pair à pair (P2P/Peer-to-Peer) open source avec la capacité de regarder des... Cliquez pour télécharger Tribler OneSwarm (2012)ONESWARM (2012)Le peer-to-peer qui protège votre vie privée, c'est OneSwarm.
Ce logiciel de peer-to-peer crypté... Cliquez pour télécharger OneSwarm PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO Academy System (17.2.1.0)ACADEMY SYSTEM (17.2.1.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Easy-Planning (1.0.0.1)EASY-PLANNING (1.0.0.1)Basé sur les mêmes principes que MyPlanning, Easy-Planning permet de créer des plannings sous la ... Cliquez pour télécharger Easy-Planning
|