MathieuBar
Messages postés1Date d'inscriptionsamedi 19 septembre 2015StatutMembreDernière intervention19 septembre 2015
-
19 sept. 2015 à 09:09
cgandco
Messages postés219Date d'inscriptionmercredi 26 octobre 2011StatutMembreDernière intervention22 juin 2017
-
22 sept. 2015 à 11:36
Bonjour,
j'ai une erreur Input string was not in a correct format quand je check mon checkbox dans mon gridview,
voila mon code aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.OleDb;
using System.Configuration;
public partial class dispo: System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(!Page.IsPostBack)
{
LoadData();
}
}
private void LoadData()
{
OleDbConnection conn = new OleDbConnection(ConfigurationManager.ConnectionStrings["dispoConnectionString"].ConnectionString);
conn.Open();
string affiche = "SELECT * FROM disponibilite";
OleDbDataAdapter da = new OleDbDataAdapter(affiche, conn);
DataTable dt = new DataTable();
da.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
conn.Close();
}
public void checkbox_OnCheckedChanged(object sender, EventArgs e)
{
CheckBox checkbox = (CheckBox)sender;
GridViewRow row = (GridViewRow)checkbox.NamingContainer;
string cocher = row.Cells[1].ToString();
bool check = checkbox.Checked;
OleDbConnection conn = new OleDbConnection(ConfigurationManager.ConnectionStrings["dispoConnectionString"].ConnectionString);
conn.Open();
String sql = "UPDATE disponibilite SET Occupation = @Occupation WHERE id = @id";
OleDbCommand com = new OleDbCommand(sql, conn);
com.Parameters.Add("@Occupation", OleDbType.Boolean).Value = check;
com.Parameters.Add("@id", OleDbType.Integer).Value = cocher;
com.ExecuteNonQuery();
conn.Close();
LoadData();
}
}
Dans mon base de données access 2013 Occupation est de type Booléen O/N et id est de type NuméroAuto(Entier Long)
Je comprend pas d'où peut venir l'erreur si quelqu'un a des idées pour m'aider un peu.
Merci.
A voir également:
C# string.format input string was not in a correct format