C Insert image to ms sql database using odbc - c

Is there any way to put image into MS SQL database on c? The table field type is "Image", i have HBITMAP in my program, how can i put it into database?
I use SQLExecDirect() function to insert text into VARCHAR fields, but i also need to work with "Image" field. Is that even possible?

This should be possible using ODBC.
If you take a look at this article: Using ODBC with Microsoft SQL Server
and scroll down to the very bottom, there is a sample app code ("Putimage.c"), using SQLExecDirect() function.

Related

Encrypt an existing SQL Server table column

Is there a way I can encrypt an existing column in a SQL Server table without changing any other systems which uses this column? I am on SQL Server 2005.
I guess it's possible in Oracle like this (after enabling Transparent Data Encryption)
ALTER TABLE employees
MODIFY (salary ENCRYPT USING '3DES168');
You can encrypt the data using PHP functions or any other scripting library functions and store them in the MySQL database. I hope this helps.

How to preview image in sql server?

I am using sql server 2012, In one of the table's column I have varbinary(max) values. This column is used to hold binary values of an Image
, where all the images are resides of my application. Now I want to opent that image in sql server itself, similary
when we write select empid from employee it is displaying empid, so is there any similary way to preview image in sql server?
also any way to doc/docx files to preview in sql server?
SQL Server does not have any way of displaying data in VARBINARY columns as images. You need a different tool for this that extracts the VARBINARY data and interprets it in the correct image format.
There is a SSMS add-in called SSMSBoost that has the feature SSMS Results Grid Visualizers.
You can get fully-functional free community license or buy the professional version. Currently both versions have the same set of features.

How to introduce a parameter to SQL server using MS Access as a front-end UI?

I am using MS Access as a front-end and using an ODBC SQL Server Driver for data.
How is that I can parameterize my query using a field from an MS Access form?
Here is my current working query (however, I need DALLAS to be a parameter I can pass from a MS Access form):
Select LPID,Name_Long, MR_Markets from baf_center
Where Guild_Markets = 'DALLAS';
Should this be handled in VBA instead?
Any help would be appreciated.
If I understand you correctly, you have field in a form and you want to use that in the where clause of a query. If so, you could reference the form field like so in the criteria of the query designer:
[Forms]![Your Form]![Your Form Field]
Let me know if I'm off-base about what you're trying to do.
Are you using linked tables to a SQL Server database. If so, it is an actual ODBC query.
You might be able to reference [Forms]![Your Form]![Your Form Field] in the criteria window entry under the Guild_Markets column. However, you have to do something with the results?
You can also execute the query via VBA.
I guess the main question is what are you trying to do?

SP that generates a SQL table from the clipboard

Retrieving data from Excel to a SQL server database is common.
Let's say I have selected 4 columns of data from Excel and I copyed this data to my Clipboard.
Q: How can I generate a table (temporary or normal) with 4 columns (could be all characters) ?
This kind of thinking is fundamentally flawed. Excel is a client application where the user interface is the application, whereas SQL Server is a server type application, where SQL management studio is provided as a facilitator, not inherent in the application itself.
It is concievably plausible that you could use a CLR stored procedure to access the clipboard but I would advise against it.

SQLServer2008 : Obfuscation or scrambling

Is it possible to obfuscate or scramble a column in SQLServer 2008 R2 without having to use encryption or some highly ineffecient custom made function that does substrings?
Why not use encryption/hashing/encoding in your application and post the results into SQL? That's pretty standard.
If you must do it in SQL Server, you may want to look at using CLR functions within SQL Server.
Not that I know of, encrypt the data coming in and out from the column with a 3rd party app like Java or .NET. If you do it within SQL then the person who steals your backup can decrypt is since he has access to the function
try something like this: obfuscate or encrypt some plain text data in PHP
Something to research a bit further here.
SQL Server 2005+ has the function - ENCRYPTBYKEY and its mate DECRYPTBYKEY
EncryptByKey Params:
key_GUID - the GUID of the key to be used to encrypt the cleartext. uniqueidentifier. This requires you to have a SYMMETRIC KEY open on the server.
cleartex - some text to be encrypted
Returns a varbinary up to 8000.
If you wanted to leverage these methods, you could create a column of type varbinary up to 8000, and save the output here.
I'd be interested to hear comments on real world usages of this function, and any anecdotes on its performance.

Resources