1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
Public Sub NewRCs_enreg(ByVal int_strat_id As Integer)
'creer un objet connexion ainsi qu'un objet command
Dim myConnexion As OleDbConnection = New System.Data.OleDb.OleDbConnection(My.Settings.Map_ConnectionString())
Dim myCommand As OleDbCommand = New System.Data.OleDb.OleDbCommand()
Dim myCommand2 As OleDbCommand = New System.Data.OleDb.OleDbCommand()
myCommand.Connection = myConnexion
Try
'on implement notre commande
' on insere une ligne vide afin de cree un nouvel id, ensuite on va recuperer ce nouveau ID pour une donner une Name
myCommand.CommandText = "insert into RCs(RC_name) values ( 'RC_' );"
'ouvre la connexion a la bdd
myConnexion.Open()
'execute notre commande
myCommand.ExecuteNonQuery()
Dim sql_rcname As String
Dim sql_LastRC_id As Integer
Dim recup_LastRc_id As Integer
recup_LastRc_id = Recupere_Last_RC_id(sql_LastRC_id)
sql_rcname = "RC_" + recup_LastRc_id.ToString()
Dim int_G_id As Integer
Dim recup_last_G_id As Integer
recup_last_G_id = Recuper_Last_G_id(int_G_id)
Select Case int_strat_id
Case 1, 3
'int_strat_id=1 OU 3 dc on creer un goal
myCommand2.CommandText = "Update RCs set RC_name='" & sql_rcname & "', G_id=" & recup_last_G_id & " where RC_id= " & recup_LastRc_id & ";"
Case 4, 5
'int_strat_id=1 OU 3 dc on creer un scenario
myCommand2.CommandText = "Update RCs set RC_name='" & sql_rcname & "' where RC_id= " & recup_LastRc_id & ";"
Case 2, 6, 7, _, 9, 10
'int_strat_id=2,6,7,8,9,10 dc on creer RIEN
myCommand2.CommandText = "Update RCs set RC_name='" & sql_rcname & "' where RC_id= " & recup_LastRc_id & ";"
End Select
myCommand2.Connection = myConnexion
myCommand2.ExecuteNonQuery()
Catch ex As OleDb.OleDbException
MessageBox.Show(ex.ToString)
End Try
'fermeture de la connexion
myConnexion.Close()
Me.RCsTableAdapter.Fill(Me.Map_DataSet.RCs)
End Sub |
Partager