Showing posts with label datatype. Show all posts
Showing posts with label datatype. Show all posts

Wednesday, March 28, 2012

how to insert images...

Complete SQL newbie here.......running SQL 2k.
I created a datatype called 'Picture' of type Image using Enterprise
Manager's Design Table function.
My question, how can I specify what the image is for a given table
row/entry? For text data types I can just type in what I want the
value to be.
Most answers I've seen talk about running scripts to do inserts.
There's got to be a drag 'n drop or File/Open type way of doing this.
I mean I remember watching people do this with a database app on a
NextStation way back when (drag n drop).....you'd think the mighty
SQL Server 2000 would have similiar abilities.
Any help appreciated.
J.Sorry, SQL Server isn't a WYSIWYG editor, and there is no drag 'n' drop
interface.
In most situations, it's probably not a good idea to store an image in your
database anyway... See for more info:
http://www.aspfaq.com/show.asp?id=2149
"James" <lee.james@.spartan.ab.ca> wrote in message
news:17084052.0403121132.1aa413a7@.posting.google.com...
> Complete SQL newbie here.......running SQL 2k.
> I created a datatype called 'Picture' of type Image using Enterprise
> Manager's Design Table function.
> My question, how can I specify what the image is for a given table
> row/entry? For text data types I can just type in what I want the
> value to be.
> Most answers I've seen talk about running scripts to do inserts.
> There's got to be a drag 'n drop or File/Open type way of doing this.
> I mean I remember watching people do this with a database app on a
> NextStation way back when (drag n drop).....you'd think the mighty
> SQL Server 2000 would have similiar abilities.
> Any help appreciated.
> J.|||Hi James,
I am reviewing you post and since we have not heard from you for some time
in the newsgroup, I wonder if our community member's information is helpful
to your question. For any more question, please post your message here and
we are glad to help.
Thanks.
Best regards
Baisong Wei
Microsoft Online Support
----
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Please reply to newsgroups only. Thanks.sql

how to insert data into to image datatype

i have a table gg. It has two fields one is ggno int, ggfig image .
how can i insert into the record into 'gg' table help me with examppleDepends on your coding language, there should be many exmaples out
there for each coding language. Normally you will need to open the
stream and fill a blob, but that is different in every coding language.

HTH, Jens Suessmeyer.

--
http://www.sqlserver2005.de
--

Monday, March 26, 2012

How to insert a byte() to a blob column?

Hi everybody,

I don't where to asked this question in this forum. How do you insert to a column of a table with a blob or binary datatype if there is one, from a byte() datatype? What is wrong? How can I fixed this? I need help. Thanks.

Code:
string sqlText = "Insert table1(id, dataByte) values('" + id + "'," + byteData + ")";

OdbcCommand cmd = new OdbcCommand(sqlText, odConn);

//opening connection here

int iRes = cmd.ExecuteNonQuery();

Result:
iRes = -1
den2005parameterize, parameterize, parameterize
read up on parameters

on a side note - never build sql!
on another side note. . . don't use odbc (there are bugs in the MDAC sql odbc driver)
use oledb. . .
better yet - use the sqlclient library

untested code (might have missed a particular point but this is the gist):



SqlDbCommand cmd = new SqlDbCommand("Insert table1(id, dataByte) values(@.id , @.data)", sqlConn);
cmd.Parameters["@.id"].ParameterValue = id;
cmd.Parameters["@.data"].ParameterValue = byteData;
int iRes = cmd.ExecuteNonQuery()

Research "how to store an image in a database" - its the same concept.
Again. . . parameterize your queries.
Insist that your peers do the same.

Security - Performance - Maintainence

and this question belongs in .Net Data Access Forum|||Thanks for reply, Blair Allen. I solved this my problem now is retrieving this BLOB from database and converting it to byte() and loading it to a Micorosft.Ink object using Ink.Load() method. The error occurs at Ink.Load() statement. Can anyone help? Thanks for advise. I'll post this problem at .Net Data Access Forum.

den2005|||I think this is it:
just hacked, not checked


byte[] bytes = null;
/* first get the size. . . */
int num = MySqlDataReader.GetBytes("myBlobField", 0, null, 0, int.MaxValue);
if (num != 0)
{
/* allocate the bytes */
bytes = new byte[num];
/* load the bytes */
MySqlDataReader.GetBytes("myBlobField", 0, bytes, 0,num)
}

cheers|||Thanks Blair Allen for reply I used a different approach. I converted the byte() to a base64 string format and then store it as a Text data in database and retrieving it as string and used Convert.FromBase64String() method to convert it back to byte() and load it to Ink.Load() and it works.

den2005

Friday, March 23, 2012

how to increase size of datatype...

Dear

I am using varchar data type in my table.it provides maximum 8000 character. but i want more than that.

how to increase size more than 8000

i want to use text datatype but when i type in length it doenst type.it displays only 16.i cant change to another value.

please help me out

Waiting for reply

Regards,
ASIFTEXT does not take a length the way VARCHAR does

it's just TEXT