about images in sql server

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="";

}
 
G

Guest

You are using Odbc for database access, Odbc uses the question mark "?" for parameter position, not @parameter

Tu-Thac
www.ongtech.co

----- Taryon wrote: ----

This is my insert routine to create an entry into the table AGENTES wit
identification, name and the photography. (105x128

when i execute it i got

"ERROR [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Must declar
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 )

tr



int numRowsAffected = cmd.ExecuteNonQuery()



catch (Exception ex



string x=""
 
T

Taryon

thx. but if i change the @ by ? i got the
"ERROR [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Must declare
the variable '@P1imgID'."

Where can i find more information about this?

thx in advance!


Tu-Thach said:
You are using Odbc for database access, Odbc uses the question mark "?"
for parameter position, not @parameter.
Tu-Thach
www.ongtech.com

----- Taryon wrote: -----

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="";

}
 
L

Lloyd Dupont

what about using an OdbcCommandBuilder to generate you commands from the
insert ?
then if you do need to set the command yourself, you could at least at what
the command builder generated, that would gives you idea at least ! ...

Taryon said:
thx. but if i change the @ by ? i got the
"ERROR [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Must declare
the variable '@P1imgID'."

Where can i find more information about this?

thx in advance!


Tu-Thach said:
You are using Odbc for database access, Odbc uses the question mark "?"
for parameter position, not @parameter.
Tu-Thach
www.ongtech.com

----- Taryon wrote: -----

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="";

}
 
T

Taryon

yeah. good idea!
thx!

Lloyd Dupont said:
what about using an OdbcCommandBuilder to generate you commands from the
insert ?
then if you do need to set the command yourself, you could at least at what
the command builder generated, that would gives you idea at least ! ...

Taryon said:
thx. but if i change the @ by ? i got the
"ERROR [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Must declare
the variable '@P1imgID'."

Where can i find more information about this?

thx in advance!


Tu-Thach said:
You are using Odbc for database access, Odbc uses the question mark
"?"
for parameter position, not @parameter.
Tu-Thach
www.ongtech.com

----- Taryon wrote: -----

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="";

}
 
G

Guest

OdbcCommand command = new OdbcCommand("insert into tablename (col1) values (?)")
OdbcParameter param = new OdbcParameter("name", OdbcType.Text, 50)
command.Parameters.Add(param)

Tu-Thac
www.ongtech.co

----- Taryon wrote: ----

thx. but if i change the @ by ? i got th
"ERROR [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Must declar
the variable '@P1imgID'.

Where can i find more information about this

thx in advance


Tu-Thach said:
You are using Odbc for database access, Odbc uses the question mark "?
for parameter position, not @parameter
Tu-Thac www.ongtech.co
----- Taryon wrote: ----
This is my insert routine to create an entry into the table AGENTE
wit
identification, name and the photography. (105x128
when i execute it i got
"ERROR [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Mus
declar
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 INT
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 )
tr

int numRowsAffected = cmd.ExecuteNonQuery()

catch (Exception ex

string x=""
 
T

Taryon

Ok. thx. works fine!

Tu-Thach said:
OdbcCommand command = new OdbcCommand("insert into tablename (col1) values (?)");
OdbcParameter param = new OdbcParameter("name", OdbcType.Text, 50);
command.Parameters.Add(param);

Tu-Thach
www.ongtech.com

----- Taryon wrote: -----

thx. but if i change the @ by ? i got the
"ERROR [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Must declare
the variable '@P1imgID'."

Where can i find more information about this?

thx in advance!


Tu-Thach said:
You are using Odbc for database access, Odbc uses the question mark
"?"
for parameter position, not @parameter. 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);
AGENTES(ID,NAME,PHOTO)
VALUES (@imgID,@imgName,@imgPhoto )", conn );
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top