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

Friday, March 23, 2012

How to get the images files size?

Hi,
I want to retrive the images from SQL database and store into microsoft access database.
But only images file which is <than 500mb is allowed to retireve.How can i get the images files size if i just store the image file name into my sql database.(there is another folder to store images)

p@.ywen.You can use something like this:


// Create a reference to the image directory.
System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(strFileDirectory);
// Create an array representing the files in the current directory.
System.IO.FileInfo[] fi = di.GetFiles("*.jpg");

// then get file size
int fileSize = fi[0].Length;

|||Thanks for your reply, but one more question here.

After i create the array to store the images, then when i wan to get the files size
i need to loop until EOF right?|||No, you can just loop through the array using a standard for or a foreach.sql

how to get the db files size ?

how to get the db files size ?Look ath this post:
http://groups.google.de/group/micro...ce71382782a1c6b
HTH, Jens Suessmeyer.

Wednesday, March 21, 2012

How to get the database file into .bak file format using C#

Hi,

I want to retrive the values from the database 'northwind' and then i want to store the backup files in"D:/Sample/north_database.bak" format(local machine).

I retrive the database values in .txt,XML format. Now i want to take in .bak format.

give the Suitable solution for this.

Subashini.G

subashi

Check out this article and then download the zip file, to see a sample of the code you want

http://www.codersource.net/csharp_sqldmo_sqlserver.aspx

HTH

|||

Hi,

They Above Article is useful for me. But this coding isstored is database Queries in text(txt) format but i need thedatabase table values stored in .bak format.

Give the solution please

|||

subashini

Take 2

Try

http://www.csharphelp.com/archives2/archive345.html

I think this gets you what you need.

HTH

|||

Thank you Very Much. This coding is very useful for me.....Smile

Regards

Subashini

Monday, March 19, 2012

How to get SQL Server 2000 data files location?

Hi.

Is any way to get SQL Server 2000 data files location using TSQL?

select filename from sysfiles|||

Thank you for your answer.

I have already considered this variant, but using a little other request:

select top 1 filename from model..sysfiles.

This is not very simple approach, becase then one must parse the path name and remove file name part at the end.

Well, if it is the only way to get result, I'll use it.

|||

Here is the parse code:

DECLARE @.path nvarchar(260)

SET @.path = RTRIM((SELECT TOP 1 filename from model..sysfiles))
SET @.path = SUBSTRING(@.path, 1, LEN(@.path) - CHARINDEX('\', REVERSE(@.path))).

Any suggestions?

|||

Can you not just take the name from sysfiles, and append the extension?

SELECT top 1 [name] + '.mdf' FROM sysfiles

|||There is no built-in method to get the data files location easily. You have to write your own to do it and your example seems fine.

How to get size of an image data type field stored in my SQL Server Database

Hi,
I have a problem and don't know how to solve it.
I am storing files (jpg, etc) in a table as binaries (image data type)
and would like to be able to show progress bar when I am loading it
from database.
But to do that, I need somehow to get the size of that file that is
stored in database (as image data type). Unfortunatelly my table does
not have a 'file_size' column from where I could get the size of image
and I am not in position to change that.
So far I am reading or writing to databasse successfully using
FileStream or BinaryREader/Writer (in VB.NET), so that is not the
problem.
Does anybody know how can I get the size of an file stored in
database?
Any help will be greatelly appreciated
Try the following function
select datalength(imagecolumn) from table where x=y
"Dino Buljubasic" <dino@.noplacelikehome.com> wrote in message
news:j74v21t1saqrl2b25cr16dnc93mo00emv3@.4ax.com...
> Hi,
> I have a problem and don't know how to solve it.
> I am storing files (jpg, etc) in a table as binaries (image data type)
> and would like to be able to show progress bar when I am loading it
> from database.
> But to do that, I need somehow to get the size of that file that is
> stored in database (as image data type). Unfortunatelly my table does
> not have a 'file_size' column from where I could get the size of image
> and I am not in position to change that.
> So far I am reading or writing to databasse successfully using
> FileStream or BinaryREader/Writer (in VB.NET), so that is not the
> problem.
> Does anybody know how can I get the size of an file stored in
> database?
> Any help will be greatelly appreciated
>

How to get size of an image data type field stored in my SQL Server Database

Hi,
I have a problem and don't know how to solve it.
I am storing files (jpg, etc) in a table as binaries (image data type)
and would like to be able to show progress bar when I am loading it
from database.
But to do that, I need somehow to get the size of that file that is
stored in database (as image data type). Unfortunatelly my table does
not have a 'file_size' column from where I could get the size of image
and I am not in position to change that.
So far I am reading or writing to databasse successfully using
FileStream or BinaryREader/Writer (in VB.NET), so that is not the
problem.
Does anybody know how can I get the size of an file stored in
database?
Any help will be greatelly appreciatedThis is a multi-part message in MIME format.
--030403020708070709060401
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
SELECT DATALENGTH(MyImageColumn), MyImageColumn, ... FROM TableOwner.MyTable
WHERE ...
--
*mike hodgson* |/ database administrator/ | mallesons stephen jaques
*T* +61 (2) 9296 3668 |* F* +61 (2) 9296 3885 |* M* +61 (408) 675 907
*E* mailto:mike.hodgson@.mallesons.nospam.com |* W* http://www.mallesons.com
Dino Buljubasic wrote:
>Hi,
>I have a problem and don't know how to solve it.
>I am storing files (jpg, etc) in a table as binaries (image data type)
>and would like to be able to show progress bar when I am loading it
>from database.
>But to do that, I need somehow to get the size of that file that is
>stored in database (as image data type). Unfortunatelly my table does
>not have a 'file_size' column from where I could get the size of image
>and I am not in position to change that.
>So far I am reading or writing to databasse successfully using
>FileStream or BinaryREader/Writer (in VB.NET), so that is not the
>problem.
>Does anybody know how can I get the size of an file stored in
>database?
>Any help will be greatelly appreciated
>
>
--030403020708070709060401
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<tt>SELECT DATALENGTH(MyImageColumn), MyImageColumn, ... FROM
TableOwner.MyTable<br>
WHERE ...<br>
</tt>
<div class="moz-signature">
<title></title>
<meta http-equiv="Content-Type" content="text/html; ">
<p><span lang="en-au"><font face="Tahoma" size="2">--<br>
</font> </span><b><span lang="en-au"><font face="Tahoma" size="2">mike
hodgson</font></span></b><span lang="en-au"> <font face="Tahoma"
size="2">|</font><i><font face="Tahoma"> </font><font face="Tahoma"
size="2"> database administrator</font></i><font face="Tahoma" size="2">
| mallesons</font><font face="Tahoma"> </font><font face="Tahoma"
size="2">stephen</font><font face="Tahoma"> </font><font face="Tahoma"
size="2"> jaques</font><font face="Tahoma"><br>
</font><b><font face="Tahoma" size="2">T</font></b><font face="Tahoma"
size="2"> +61 (2) 9296 3668 |</font><b><font face="Tahoma"> </font><font
face="Tahoma" size="2"> F</font></b><font face="Tahoma" size="2"> +61
(2) 9296 3885 |</font><b><font face="Tahoma"> </font><font
face="Tahoma" size="2">M</font></b><font face="Tahoma" size="2"> +61
(408) 675 907</font><br>
<b><font face="Tahoma" size="2">E</font></b><font face="Tahoma" size="2">
<a href="http://links.10026.com/?link=mailto:mike.hodgson@.mallesons.nospam.com">
mailto:mike.hodgson@.mallesons.nospam.com</a> |</font><b><font
face="Tahoma"> </font><font face="Tahoma" size="2">W</font></b><font
face="Tahoma" size="2"> <a href="http://links.10026.com/?link=/">http://www.mallesons.com">
http://www.mallesons.com</a></font></span> </p>
</div>
<br>
<br>
Dino Buljubasic wrote:
<blockquote cite="midj74v21t1saqrl2b25cr16dnc93mo00emv3@.4ax.com"
type="cite">
<pre wrap="">Hi,
I have a problem and don't know how to solve it.
I am storing files (jpg, etc) in a table as binaries (image data type)
and would like to be able to show progress bar when I am loading it
from database.
But to do that, I need somehow to get the size of that file that is
stored in database (as image data type). Unfortunatelly my table does
not have a 'file_size' column from where I could get the size of image
and I am not in position to change that.
So far I am reading or writing to databasse successfully using
FileStream or BinaryREader/Writer (in VB.NET), so that is not the
problem.
Does anybody know how can I get the size of an file stored in
database?
Any help will be greatelly appreciated
</pre>
</blockquote>
</body>
</html>
--030403020708070709060401--|||Try the following function
select datalength(imagecolumn) from table where x=y
"Dino Buljubasic" <dino@.noplacelikehome.com> wrote in message
news:j74v21t1saqrl2b25cr16dnc93mo00emv3@.4ax.com...
> Hi,
> I have a problem and don't know how to solve it.
> I am storing files (jpg, etc) in a table as binaries (image data type)
> and would like to be able to show progress bar when I am loading it
> from database.
> But to do that, I need somehow to get the size of that file that is
> stored in database (as image data type). Unfortunatelly my table does
> not have a 'file_size' column from where I could get the size of image
> and I am not in position to change that.
> So far I am reading or writing to databasse successfully using
> FileStream or BinaryREader/Writer (in VB.NET), so that is not the
> problem.
> Does anybody know how can I get the size of an file stored in
> database?
> Any help will be greatelly appreciated
>

How to get size of an image data type field stored in my SQL Server Database

Hi,
I have a problem and don't know how to solve it.
I am storing files (jpg, etc) in a table as binaries (image data type)
and would like to be able to show progress bar when I am loading it
from database.
But to do that, I need somehow to get the size of that file that is
stored in database (as image data type). Unfortunatelly my table does
not have a 'file_size' column from where I could get the size of image
and I am not in position to change that.
So far I am reading or writing to databasse successfully using
FileStream or BinaryREader/Writer (in VB.NET), so that is not the
problem.
Does anybody know how can I get the size of an file stored in
database?
Any help will be greatelly appreciatedTry the following function
select datalength(imagecolumn) from table where x=y
"Dino Buljubasic" <dino@.noplacelikehome.com> wrote in message
news:j74v21t1saqrl2b25cr16dnc93mo00emv3@.
4ax.com...
> Hi,
> I have a problem and don't know how to solve it.
> I am storing files (jpg, etc) in a table as binaries (image data type)
> and would like to be able to show progress bar when I am loading it
> from database.
> But to do that, I need somehow to get the size of that file that is
> stored in database (as image data type). Unfortunatelly my table does
> not have a 'file_size' column from where I could get the size of image
> and I am not in position to change that.
> So far I am reading or writing to databasse successfully using
> FileStream or BinaryREader/Writer (in VB.NET), so that is not the
> problem.
> Does anybody know how can I get the size of an file stored in
> database?
> Any help will be greatelly appreciated
>

Monday, March 12, 2012

How to get return value for the number of rows affected by update command

Hi,

i read from help files that "For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command. " Anyone know how to get the return value from the query below?

Below is the normal way i did in vb.net, but how to check for the return value. Please help.

========
Public Sub CreateMySqlCommand(myExecuteQuery As String, myConnection As SqlConnection)
Dim myCommand As New SqlCommand(myExecuteQuery, myConnection)
myCommand.Connection.Open()
myCommand.ExecuteNonQuery()
myConnection.Close()
End Sub 'CreateMySqlCommand
========

Thank you.you can add either of these statements to the SQL being called
[BOL} @.@.rowcount
[BOL] Rowcount_big

the difference is in the datatypes rowcount _big returns a bigint
and @.@.rowcount returns int

if you have over 2 billion rows user rowcount_big|||Hi Ruprect, thanks for your reply. My sql statement is a very simple insert query without using any parameters just like the one below:

sql = "INSERT INTO [Subscriber] ([SubID], [SubName], [SubEmail], [Status], [MailID], [SubscribeDate]) VALUES (SubID, SubName, SubEmail, 'Pending', MailID ,getDate())"

I'm unsure of how to include the " [BOL} @.@.rowcount ". Do you mean that i should add a parameter to return @.@.rowcount or there is other way to do it? I'm new to this, would you please give me an example.

Thanks for your time.|||@.@.Rowcount stored the number of records affected by the immediately prior statement. The value is lost as soon as another statement is executed, so you must either use it immediately or store it in a procedure variable:

declare @.RecordsAffected Int
.
.
.
.
.
Update/Select/Delete some records from somewhere...
set @.RecordsAffected = @.@.RowCount

Look up @.@.Rowcount in Books Online for more details.|||thanks BLIND MAN
i didnt getthis until late
[BOL] stands for Books Online it's the sql server help file
i was giving you the article title

and since blindman got it exactly i've no need to reiterate
good luck.|||see if there is something like mycommand.rowsaffected property.|||Thanks Blindman and Thanks Ruprect. I'll study BOL ;) for details of @.@.rowcount.|||You should also follow ms_sql_dba's suggestion to see if there is a method to return the value via VB.

It might be more appropriate if you are going to use the value in your VB code.|||Hi ms_sql_dba, there isn't any rowsaffected property, however there is this UpdatedRowSource and others ..

Thanks for your suggestion, although i'm unsure of their usage, i'll look into it and see if i can find something which stores the value of number of rows affected!|||Sure Blindman, i'll study both ways and see which one is more applicable for my situation. You have a great day.|||Hi Everyone,

I managed to find another solution to my question. Just simply assign the value like this line:-

rowsAffected = myCommand.ExecuteNonQuery()|||see, it was simple!|||Yea. Lesson learned! Cheers!!!

Friday, March 9, 2012

How to get parameters in XSLT from template files...

I'd like to get the HTTP parameters to a form in both the XML template and
the XSLT.
I know that I can use <sql:param> to get the parameter for use in my SQL.
But why doesn't it also get passed to the XSLT as <xsl:param> values for me
to use?
PerWe cannot pass the variables to the stylesheet that way unfortunately. The
best way is to add them to the XML document that you pass to the stylesheet
and then take them and use them throughout your XSLT.
Best regards
Michael
"Per" <anonymous@.discussions.microsoft.com> wrote in message
news:uc4rlHEJFHA.904@.tk2msftngp13.phx.gbl...
> I'd like to get the HTTP parameters to a form in both the XML template and
> the XSLT.
> I know that I can use <sql:param> to get the parameter for use in my SQL.
> But why doesn't it also get passed to the XSLT as <xsl:param> values for
> me to use?
> Per
>

How to get parameters in XSLT from template files...

I'd like to get the HTTP parameters to a form in both the XML template and
the XSLT.
I know that I can use <sql:param> to get the parameter for use in my SQL.
But why doesn't it also get passed to the XSLT as <xsl:param> values for me
to use?
Per
We cannot pass the variables to the stylesheet that way unfortunately. The
best way is to add them to the XML document that you pass to the stylesheet
and then take them and use them throughout your XSLT.
Best regards
Michael
"Per" <anonymous@.discussions.microsoft.com> wrote in message
news:uc4rlHEJFHA.904@.tk2msftngp13.phx.gbl...
> I'd like to get the HTTP parameters to a form in both the XML template and
> the XSLT.
> I know that I can use <sql:param> to get the parameter for use in my SQL.
> But why doesn't it also get passed to the XSLT as <xsl:param> values for
> me to use?
> Per
>

Friday, February 24, 2012

How to get list of backup log files from msdb of standby server?

How do we retrieve log file names of primary backup from msdb of
standby database?
In case of primary server unavailable, I need to get the logfile names
from standby server for disater recovery test.
Thanks in advance
Tram
Msdb..backupfile gives you a list of data/log files that are backed up.
For logshipping, take a look at msdb..log_shipping_plan_databases.
-oj
"tram" <tram_e@.hotmail.com> wrote in message
news:1120079449.879078.169120@.o13g2000cwo.googlegr oups.com...
> How do we retrieve log file names of primary backup from msdb of
> standby database?
> In case of primary server unavailable, I need to get the logfile names
> from standby server for disater recovery test.
> Thanks in advance
> Tram
>

How to get list of backup log files from msdb of standby server?

How do we retrieve log file names of primary backup from msdb of
standby database?
In case of primary server unavailable, I need to get the logfile names
from standby server for disater recovery test.
Thanks in advance
TramMsdb..backupfile gives you a list of data/log files that are backed up.
For logshipping, take a look at msdb..log_shipping_plan_databases.
-oj
"tram" <tram_e@.hotmail.com> wrote in message
news:1120079449.879078.169120@.o13g2000cwo.googlegroups.com...
> How do we retrieve log file names of primary backup from msdb of
> standby database?
> In case of primary server unavailable, I need to get the logfile names
> from standby server for disater recovery test.
> Thanks in advance
> Tram
>

How to get list of backup log files from msdb of standby server?

How do we retrieve log file names of primary backup from msdb of
standby database?
In case of primary server unavailable, I need to get the logfile names
from standby server for disater recovery test.
Thanks in advance
TramMsdb..backupfile gives you a list of data/log files that are backed up.
For logshipping, take a look at msdb..log_shipping_plan_databases.
--
-oj
"tram" <tram_e@.hotmail.com> wrote in message
news:1120079449.879078.169120@.o13g2000cwo.googlegroups.com...
> How do we retrieve log file names of primary backup from msdb of
> standby database?
> In case of primary server unavailable, I need to get the logfile names
> from standby server for disater recovery test.
> Thanks in advance
> Tram
>

how to get latest file

how to get the name of the latest file of a particular directory
thru query
i.e
i have files in a directory
1130am.txt
11.45am.txt
1200am.txt
my query should return 1200am.txtOriginally posted by vrsrinivas
how to get the name of the latest file of a particular directory
thru query

i.e
i have files in a directory

1130am.txt
11.45am.txt
1200am.txt

my query should return 1200am.txt

Assuming that all your file names are prefixed with a time stamp then you should be able to use the MAX() function to return the desired record.

create table #test (theFileName varchar(20))

insert into #test (theFileName) values ('1130am.txt')
insert into #test (theFileName) values ('11.45am.txt')
insert into #test (theFileName) values ('1200am.txt')

select max(theFileName) from #test|||I'm thinking the hard part is getting the info from the directory...

Delete From Ledger_Folder

Insert Into Ledger_Folder exec master..xp_cmdshell 'Dir d:\Data\Tax\SmartStreamExtracts\*.*'

Delete From Ledger_Folder_Parsed

Insert Into Ledger_Folder_Parsed (Create_Time, File_Size, File_Name )
Select Convert(datetime,Substring(dir_output,1,8)
+ ' '
+ (Substring(dir_output,11,5)
+ Case When Substring(dir_output,16,1) = 'a' Then ' AM' Else ' PM' End)) As Create_Time
, Convert(Int,LTrim(RTrim(Replace(Substring(dir_outp ut,17,22),',','')))) As File_Size
, Substring(dir_output,40,(Len(dir_output)-39)) As File_Name
From Ledger_Folder
Where Substring(dir_output,1,1) <> ' '
And (Substring(dir_output,1,1) <> ' '
And Substring(dir_output,25,5) <> '<DIR>')

Sunday, February 19, 2012

how to get file list from sysfiles table of .mdf

hi,
i have a strange requirement.
I have all the .mdf/.ndf/.ldf files for a given
database on different drives of same server.
I do not know which files put together make up the
database.
so in order to exec sp_attachdb or "create database
wit attach" syntax (files >16)
from where do i get the list of files pertaining to 1
db.
Can i access/read sysfiles system table in the .mdf
before attaching it.
any suggestion wud be welcome
Thanks
RahulIt's a reasonable requirement, but...
You'll have to keep track of the list of db files yourself.
You can't query a database file before it's attached.
However, if you haven't moved the files since they were detached, all you
need do is attach the primary datafile and it will find the other files (it
internally scans "sysfiles" during the attach to perform this).
"rahulnagarmath" <rahulnagarmath@.hotmail.com> wrote in message
news:2891001c39148$292d18c0$a601280a@.phx.gbl...
> hi,
> i have a strange requirement.
> I have all the .mdf/.ndf/.ldf files for a given
> database on different drives of same server.
> I do not know which files put together make up the
> database.
> so in order to exec sp_attachdb or "create database
> wit attach" syntax (files >16)
> from where do i get the list of files pertaining to 1
> db.
> Can i access/read sysfiles system table in the .mdf
> before attaching it.
> any suggestion wud be welcome
> Thanks
> Rahul
>