0

I'm trying to change my column datatype in the table item. Now it has just 0(it's int now). What will happen when I run it? I tried to use int num = cmd.ExecuteNonQuery() but didn't work, it came an error. With this code I don't see changes. I found that LONGBLOB is the particular datatype for saving images in the database. This is my code:

public partial class alterOneSec : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        OleDbConnection con = DAL.GetConnection();
        con.Open();
        if(con.State == ConnectionState.Open)
        {
            string sql = "ALTER TABLE item ALTER COLUMN picture LONGBLOB NOT NULL";
            OleDbCommand cmd = DAL.GetCommand(con, sql);
        }
        con.Close();
        Response.Redirect("homepage.aspx?err=case3");
    }
}

The GetCommand method is this:

public static OleDbCommand GetCommand(OleDbConnection con, string sql)
    {
        OleDbCommand cmd = new OleDbCommand();
        cmd.Connection = con;
        cmd.CommandType = CommandType.Text;
        cmd.CommandText = sql;
        return cmd;
    }
Pichi Wuana
  • 732
  • 2
  • 9
  • 35
  • Hi, "an error" is not very useful most of the time. No doubt, you can provide some more information? What is the exact error you are getting? – wvdz Jun 24 '15 at 20:55
  • @popovitsj The first problem is that I actually don't see a difference in my table... And second, when I tried to do `cmd.ExecuteNonQuery();` it went to an exception. – Pichi Wuana Jun 24 '15 at 20:58
  • Have you tried dropping and recreating the column? – wvdz Jun 24 '15 at 21:04

0 Answers0