Showing posts with label files. Show all posts
Showing posts with label files. Show all posts

Tuesday, March 27, 2012

accessing image files stored as binary data

Hi

When images are uploaded and stored directly into a sql database as binary data (eg in the club starter kit) how can those images be accessed and displayed.

When I open the images table in VWD and select display data, the cells holding the image data hold a <binary data> tag. What I want to be able to do is get at that data, or actually get at the image so that it is displayed. My reason is this, at the moment the only way to access the images in the sql database after they have been uploaded is to log into the website and view them as an administrator of the site. It would be much simpler if I could access the database directly and view the contents of the images table.

Any ideas?

Thanks

If you're trying to displaying the image stored in sql server from a grid view, perhaps you should read the following post:

http://forums.asp.net/thread/1337670.aspx

Hope that helps

|||This is the same post you made here:http://forums.asp.net/thread/1337011.aspx. Please do not post the same question multiple times.

Thursday, March 22, 2012

Accessing current active trace file

Hi,
I am using the following SQL query for retrieving the Trace file
information.
SELECT * FROM ::fn_trace_gettable('C:\Program Files\Microsoft SQL
Server\MSSQL\Data\audittrace_20040822191554.trc', default)
But I am getting following error:
"File 'C:\Program Files\Microsoft SQL
Server\MSSQL\Data\audittrace_20040822191554.trc' either does not exist
or is not a recognizable trace file. Or there was an error opening the
file."
So, can we get the data from the current active trace file?
Thanks and Regards,
Pramod.Hi
The trace needs to be stopped and the file closed before re-opening it.
See:
http://support.microsoft.com/default.aspx?scid=kb;en-us;270599
John
"ipramod@.gmail.com" wrote:
> Hi,
> I am using the following SQL query for retrieving the Trace file
> information.
> SELECT * FROM ::fn_trace_gettable('C:\Program Files\Microsoft SQL
> Server\MSSQL\Data\audittrace_20040822191554.trc', default)
> But I am getting following error:
> "File 'C:\Program Files\Microsoft SQL
> Server\MSSQL\Data\audittrace_20040822191554.trc' either does not exist
> or is not a recognizable trace file. Or there was an error opening the
> file."
> So, can we get the data from the current active trace file?
> Thanks and Regards,
> Pramod.
>|||The trace cannot be read whilst active in SQL2000 however SQL2005 has
improved on this and does allow reading a currently active server side trace
using fn_trace_gettable or the Profiler GUI.
--
HTH
Jasper Smith (SQL Server MVP)
http://www.sqldbatips.com
I support PASS - the definitive, global
community for SQL Server professionals -
http://www.sqlpass.org
<ipramod@.gmail.com> wrote in message
news:1128422380.248267.85480@.f14g2000cwb.googlegroups.com...
> Hi,
> I am using the following SQL query for retrieving the Trace file
> information.
> SELECT * FROM ::fn_trace_gettable('C:\Program Files\Microsoft SQL
> Server\MSSQL\Data\audittrace_20040822191554.trc', default)
> But I am getting following error:
> "File 'C:\Program Files\Microsoft SQL
> Server\MSSQL\Data\audittrace_20040822191554.trc' either does not exist
> or is not a recognizable trace file. Or there was an error opening the
> file."
> So, can we get the data from the current active trace file?
> Thanks and Regards,
> Pramod.
>

Accessing current active trace file

Hi,
I am using the following SQL query for retrieving the Trace file
information.
SELECT * FROM ::fn_trace_gettable('C:\Program Files\Microsoft SQL
Server\MSSQL\Data\audittrace_20040822191554.trc', default)
But I am getting following error:
"File 'C:\Program Files\Microsoft SQL
Server\MSSQL\Data\audittrace_20040822191554.trc' either does not exist
or is not a recognizable trace file. Or there was an error opening the
file."
So, can we get the data from the current active trace file?
Thanks and Regards,
Pramod.
Hi
The trace needs to be stopped and the file closed before re-opening it.
See:
http://support.microsoft.com/default...b;en-us;270599
John
"ipramod@.gmail.com" wrote:

> Hi,
> I am using the following SQL query for retrieving the Trace file
> information.
> SELECT * FROM ::fn_trace_gettable('C:\Program Files\Microsoft SQL
> Server\MSSQL\Data\audittrace_20040822191554.trc', default)
> But I am getting following error:
> "File 'C:\Program Files\Microsoft SQL
> Server\MSSQL\Data\audittrace_20040822191554.trc' either does not exist
> or is not a recognizable trace file. Or there was an error opening the
> file."
> So, can we get the data from the current active trace file?
> Thanks and Regards,
> Pramod.
>
|||The trace cannot be read whilst active in SQL2000 however SQL2005 has
improved on this and does allow reading a currently active server side trace
using fn_trace_gettable or the Profiler GUI.
HTH
Jasper Smith (SQL Server MVP)
http://www.sqldbatips.com
I support PASS - the definitive, global
community for SQL Server professionals -
http://www.sqlpass.org
<ipramod@.gmail.com> wrote in message
news:1128422380.248267.85480@.f14g2000cwb.googlegro ups.com...
> Hi,
> I am using the following SQL query for retrieving the Trace file
> information.
> SELECT * FROM ::fn_trace_gettable('C:\Program Files\Microsoft SQL
> Server\MSSQL\Data\audittrace_20040822191554.trc', default)
> But I am getting following error:
> "File 'C:\Program Files\Microsoft SQL
> Server\MSSQL\Data\audittrace_20040822191554.trc' either does not exist
> or is not a recognizable trace file. Or there was an error opening the
> file."
> So, can we get the data from the current active trace file?
> Thanks and Regards,
> Pramod.
>

Accessing current active trace file

Hi,
I am using the following SQL query for retrieving the Trace file
information.
SELECT * FROM ::fn_trace_gettable('C:\Program Files\Microsoft SQL
Server\MSSQL\Data\audittrace_20040822191
554.trc', default)
But I am getting following error:
"File 'C:\Program Files\Microsoft SQL
Server\MSSQL\Data\audittrace_20040822191
554.trc' either does not exist
or is not a recognizable trace file. Or there was an error opening the
file."
So, can we get the data from the current active trace file?
Thanks and Regards,
Pramod.Hi
The trace needs to be stopped and the file closed before re-opening it.
See:
http://support.microsoft.com/defaul...kb;en-us;270599
John
"ipramod@.gmail.com" wrote:

> Hi,
> I am using the following SQL query for retrieving the Trace file
> information.
> SELECT * FROM ::fn_trace_gettable('C:\Program Files\Microsoft SQL
> Server\MSSQL\Data\audittrace_20040822191
554.trc', default)
> But I am getting following error:
> "File 'C:\Program Files\Microsoft SQL
> Server\MSSQL\Data\audittrace_20040822191
554.trc' either does not exist
> or is not a recognizable trace file. Or there was an error opening the
> file."
> So, can we get the data from the current active trace file?
> Thanks and Regards,
> Pramod.
>|||The trace cannot be read whilst active in SQL2000 however SQL2005 has
improved on this and does allow reading a currently active server side trace
using fn_trace_gettable or the Profiler GUI.
HTH
Jasper Smith (SQL Server MVP)
http://www.sqldbatips.com
I support PASS - the definitive, global
community for SQL Server professionals -
http://www.sqlpass.org
<ipramod@.gmail.com> wrote in message
news:1128422380.248267.85480@.f14g2000cwb.googlegroups.com...
> Hi,
> I am using the following SQL query for retrieving the Trace file
> information.
> SELECT * FROM ::fn_trace_gettable('C:\Program Files\Microsoft SQL
> Server\MSSQL\Data\audittrace_20040822191
554.trc', default)
> But I am getting following error:
> "File 'C:\Program Files\Microsoft SQL
> Server\MSSQL\Data\audittrace_20040822191
554.trc' either does not exist
> or is not a recognizable trace file. Or there was an error opening the
> file."
> So, can we get the data from the current active trace file?
> Thanks and Regards,
> Pramod.
>

Thursday, March 8, 2012

Access to Sql server : file Size

I have migrated an Access Database to SQL server.

The original Access MDB file was around 50Mo.

After migration, I get 2 files in SQL directories :
xxx_data.mdf of around 100 Mo
and xxx_log.ldf of around 130 Mo

So the needed space is more than 4 times more than used under Access.

Is this normal, or is there something Wrong somewhere ?

Thanks for any Infos,
Pierre.Firstly the "data" component for your database is typically only stored in the xxx_data.mdf file, so it looks like it is around twice the size of your access db. You should back up your database, truncate and shirnk your transaction log.. see BOL for more info on transaction logs. This will control the size of your xxx_log.ldf file.

Next you can check how much of the 100Mb your data is actually consuming by running a a command like sp_spaceused. I'm not sure if Access has the concept of "devices" but I don't believe that it does. Have a read of this in BOL and maybe that will give you a hand..

Hope this helps.

Originally posted by Plarde
I have migrated an Access Database to SQL server.

The original Access MDB file was around 50Mo.

After migration, I get 2 files in SQL directories :
xxx_data.mdf of around 100 Mo
and xxx_log.ldf of around 130 Mo

So the needed space is more than 4 times more than used under Access.

Is this normal, or is there something Wrong somewhere ?

Thanks for any Infos,
Pierre.|||As specified make sure you didn't hit any errors during this upsizing from Access. And also assess the size of the files and schedule correct intervals of Tlog and database backups to avoid any out of space errors.

Occassionally refer to SQL error log for any information.|||Thanks for your advise.
But I am completly new with SQL server, and I do not see any tools
in SQL Manager to shrink/compact the database.

Where are these tools ?

Even in the BOL, I do not see anything talking about reducing space.

Thanks for any help.|||What version of SQL Server are you running?

Originally posted by Plarde
Thanks for your advise.
But I am completly new with SQL server, and I do not see any tools
in SQL Manager to shrink/compact the database.

Where are these tools ?

Even in the BOL, I do not see anything talking about reducing space.

Thanks for any help.|||True, you didn't mentioned version of SQL server used and make sure your login has SYSADMIN privileges to carry on those tasks.

Refer to BOL for SP_ATTACH_DB & SP_DETACH_DB topics which involves attaching/detaching process.

And make sure you have client tools installed on your machine to talk to the SQL server which has been migrated.

Thursday, February 9, 2012

Access denied to files

Hi,

Im trying to "use" files during my flow in two diferent kind of components (send email task and custom transformation), but the error i get is similar: access denied, file doesnt exists, is locked by another proccess or not enough rigths.

-In custom transofrmation i am trying to write to a file with the next code:

Dim sw As StreamWriter

If (Not File.Exists(".\test.txt")) Then

sw = File.CreateText(".\test.txt")

Else

sw = File.AppendText(".\test.txt")

End If

sw.Write("Numero de Registros en Empresas")

sw.WriteLine(Row.CuentaRegEmpresas)

sw.Write("Numero de Registros en Reporta")

sw.WriteLine(Row.CuentaRegReporta)

sw.Write("Numero de Registros de Facturas ampliadas")

sw.WriteLine(Row.CuentaRegFAmp)

sw.WriteLine()

- In send email tranformation i am trying to attach a different file (the log of the process) , but the error is that i dont have rights to access. If i try to send another file this error disappears...

Both files (test.txt and log.txt) have total control rights to all users, and arent locked or opened by any other process during the execution.

Edit: Thats the error trace i get:

en System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)

en System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)

en System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)

en System.IO.StreamWriter.CreateFile(String path, Boolean append)

en System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize)

en System.IO.StreamWriter..ctor(String path, Boolean append)

en System.IO.File.AppendText(String path)

en ScriptComponent_14cd101f436a42b18dc68087869033b2.ScriptMain.Entrada0_ProcessInputRow(Entrada0Buffer Row)

en ScriptComponent_14cd101f436a42b18dc68087869033b2.UserComponent.Entrada0_ProcessInput(Entrada0Buffer Buffer)

en ScriptComponent_14cd101f436a42b18dc68087869033b2.UserComponent.ProcessInput(Int32 InputID, PipelineBuffer Buffer)

en Microsoft.SqlServer.Dts.Pipeline.ScriptComponentHost.ProcessInput(Int32 inputID, PipelineBuffer buffer)

You mention three different errors, can you be clear about which error happens when? Please post the exact error message as well.

Can you also explain more about the tasks, and the order they are executed within your package.

The code snippet above seems incomplete, and also rather strang, perhaps if you posted the full code it would make more sense. Based on what you have posted I'd say it is wrong, as opening the file for each row is a bad idea, and you do not close the file.

As an aside the syntax seems complicated, to append to a file, just use the constructor overload -

Code Snippet

StreamWriter stream = new StreamWriter("C:\Test.txt", true);

stream.WriteLine("Test");

stream.Close();

|||

Hi Darren,

Your are right, the problem of the custom transformation was that i did not close the StreamWriter, now it's working fine.

The other problem is that, at the end of the process i want to send the log file, but it seems like the process locks the file and cant be attached in the email... am i wrong? i will try to send the email in other package inside the same project... Its possible to send parameters to the new package?

Any other idea to send the log via email just at the end of the process?

Thanks

Edit: I have proved this solution and it doesnt work... log file cant be send using a different package inside the project.

|||Why is the file locked? If you are in control of writing the file, then you should have closed and therefore released all locks to the file, so the file should be available to send. You must have something open still. Ultimately you can use something like Process Moniotor of File? (I forget to find who has the lock), the old SysInternals tools, now MS.|||The file that is locked is the log of the process... i have read in other post that is not possible to send it becuase the own process locks it, so i decide to send via email only the errors stored in @.[System::ErrorDescription]

variable when an error event is raised.

thanks