Torna al Thread

Protected Sub SaveButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SaveButton.Click Dim MySQLConnStringName, MySQLstrConnection As String Dim MySQLConn As MySqlConnection Dim MySQLSelectCmd As MySqlCommand Dim MySQLDr As MySqlDataReader = Nothing Dim UltimoOdgOds, NuovoOdgOds As Integer 'esegue la connessione al database MySQLConnStringName = "odg-odsConnectionString" MySQLstrConnection = ConfigurationManager.ConnectionStrings(MySQLConnStringName).ConnectionString MySQLConn = New MySqlConnection(MySQLstrConnection) 'ricava il numero per il nuovo odg ods MySQLSelectCmd = New MySqlCommand("SELECT MAX(Numero_odg_ods) AS Ultimo FROM(tbl_odg_ods)WHERE (Anno_competenza = YEAR(NOW())) AND (Tipo = ?Odgtipo)", MySQLConn) MySQLSelectCmd.Parameters.AddWithValue("?Odgtipo", AddTipoDropDownList.SelectedValue) MySQLConn.Open() MySQLDr = MySQLSelectCmd.ExecuteReader MySQLDr.Read() If MySQLDr.Read() Then UltimoOdgOds = MySQLDr.GetInt32("Ultimo") NuovoOdgOds = UltimoOdgOds + 1 Else NuovoOdgOds = 1 End If MySQLDr.Close() MySQLConn.Close() Label2.Text = NuovoOdgOds End Sub
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5