T
Taryon
This is my insert routine to create an entry into the table AGENTES with
identification, name and the photography. (105x128)
when i execute it i got :
"ERROR [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Must declare
the variable '@imgID'."
any idea?
thx in advance!
MemoryStream memoryStream = new MemoryStream();
byte[] imageBytes=null;
button1.Image.Save(memoryStream,System.Drawing.Imaging.ImageFormat.Gif);
imageBytes = memoryStream.ToArray();
memoryStream.Close();
OdbcCommand cmd = new OdbcCommand ("INSERT INTO AGENTES(ID,NAME,PHOTO)
VALUES (@imgID,@imgName,@imgPhoto )", conn );
OdbcParameter paramTitle = new OdbcParameter( "@imgID", OdbcType.Char,10 );
paramTitle.Value = tbID.Text;
cmd.Parameters.Add( paramTitle);
OdbcParameter paramData = new OdbcParameter( "@imgPhoto", OdbcType.Image );
paramData.Value = imageBytes;
cmd.Parameters.Add( paramData );
OdbcParameter paramType = new OdbcParameter( "@imgName",
OdbcType.VarChar,50 );
paramType.Value = tbName.Text;
cmd.Parameters.Add( paramType );
try
{
int numRowsAffected = cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
string x="";
}
identification, name and the photography. (105x128)
when i execute it i got :
"ERROR [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Must declare
the variable '@imgID'."
any idea?
thx in advance!
MemoryStream memoryStream = new MemoryStream();
byte[] imageBytes=null;
button1.Image.Save(memoryStream,System.Drawing.Imaging.ImageFormat.Gif);
imageBytes = memoryStream.ToArray();
memoryStream.Close();
OdbcCommand cmd = new OdbcCommand ("INSERT INTO AGENTES(ID,NAME,PHOTO)
VALUES (@imgID,@imgName,@imgPhoto )", conn );
OdbcParameter paramTitle = new OdbcParameter( "@imgID", OdbcType.Char,10 );
paramTitle.Value = tbID.Text;
cmd.Parameters.Add( paramTitle);
OdbcParameter paramData = new OdbcParameter( "@imgPhoto", OdbcType.Image );
paramData.Value = imageBytes;
cmd.Parameters.Add( paramData );
OdbcParameter paramType = new OdbcParameter( "@imgName",
OdbcType.VarChar,50 );
paramType.Value = tbName.Text;
cmd.Parameters.Add( paramType );
try
{
int numRowsAffected = cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
string x="";
}