ALTER TABLE doesn't work

827 views Asked by At

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;
    }
0

There are 0 answers