Showing posts with label everybody. Show all posts
Showing posts with label everybody. Show all posts

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

Monday, March 12, 2012

How to import MySQL data into SQL2005 using wizard?

Hello everybody,

I'm a new SQL2005 user.
I'm

trying to import data from MySQL version 5x into my SQL2005 by wizard.

I created a DNS file and tested successfully using MySQL Connector/ODBC

v5.
Everthing seems fine but at the last step selecting data

source. The SQL2005 wizard forced me to choose using SQL command option

instead of selecting tables/views from a list. Anyone can tell me why?

My collegues faced the same case as they help me to find the reason.

I'm sure that there are a few source objetcts in MySQL source.

Any help will be appreciated!!!

khanhmy

Hi,

Unfortunately this is the limitation of the Import/Export Wizard in SQL 2005. It can't get table metadata for ADO.NET and ODBC sources, so the only way to use it with ADO.NET or ODBC sources is to type the SQL command.

We are looking at fixing this for next version.

Regards,

Michael.

Sunday, February 19, 2012

How to i hide my database schema from...

everybody except 1 login which is non-sa in sql server 2000.
Even sa should not be able to access the schema.
Also are there anyways encrypt data in sql server 2000w
Anyone who has access to the database has access to examine, but not
necessarily modify, the schema.
If you Google for encryption and SQL Server you should find a couple of
hits. I assume that you want the data encrypted in the database.
If you mean the files themselves, an alternative is to use NTFS encryption
on the files.
Russell Fields
"w" <wilcorning@.hotmail.com> wrote in message
news:6a24cdf7.0402261134.be0b6ca@.posting.google.com...
> everybody except 1 login which is non-sa in sql server 2000.
> Even sa should not be able to access the schema.
> Also are there anyways encrypt data in sql server 2000

How to i hide my database schema from...

everybody except 1 login which is non-sa in sql server 2000.
Even sa should not be able to access the schema.
Also are there anyways encrypt data in sql server 2000w
Anyone who has access to the database has access to examine, but not
necessarily modify, the schema.
If you Google for encryption and SQL Server you should find a couple of
hits. I assume that you want the data encrypted in the database.
If you mean the files themselves, an alternative is to use NTFS encryption
on the files.
Russell Fields
"w" <wilcorning@.hotmail.com> wrote in message
news:6a24cdf7.0402261134.be0b6ca@.posting.google.com...
> everybody except 1 login which is non-sa in sql server 2000.
> Even sa should not be able to access the schema.
> Also are there anyways encrypt data in sql server 2000