Dear friends,
After inserting a word document in an image field, is it possible to
retrieve the same file and store it to some of the windows folder:
1. through SQL Server Stored Procedure?
2. though any other means like .Net code etc..
Thnaks in anticipation
Regards
Sathian> After inserting a word document in an image field, is it possible to
> retrieve the same file and store it to some of the windows folder:
> 1. through SQL Server Stored Procedure?
No idea, but would you want to? T-SQL was not designed for this.
> 2. though any other means like .Net code etc..
Absolutely. It's a piece of cake. Remember that an image field is nothing mo
re
than an array of bytes. All you do is creata a FileStream and set it's conte
nts
to that of the byte array from the image field.
Thomas|||Hello thomas,
Thank you very much.
Any sample piece of code wiich does so..?
I tried in net.. so far I wasn't sucessful..
Regards
Sathian
"Thomas" <thomas@.newsgroup.nospam> wrote in message
news:eoguWJXQFHA.2876@.TK2MSFTNGP09.phx.gbl...
> No idea, but would you want to? T-SQL was not designed for this.
>
> Absolutely. It's a piece of cake. Remember that an image field is nothing
more
> than an array of bytes. All you do is creata a FileStream and set it's
contents
> to that of the byte array from the image field.
>
> Thomas
>|||Although this is not the forum for this sort of question...
private const string connStr = ...
public void ReadFromDBToFile(string destFilePath)
{
byte[] data = null;
using (SqlConnection conn = new SqlConnection(connStr))
{
StringBuilder sb = new StringBuilder();
sb.Append("Select Content, DataLength(Content) As Len");
sb.AppendFormat("\nFrom dbo.TableName");
sb.AppendFormat("\nWhere PK = @.PK");
conn.Open();
using (SqlCommand cmd = new SqlCommand(sb.ToString(), conn))
{
cmd.Parameters.Add("@.PK", SqlDbType...);
cmd.Parameters[0].Value = <pk>
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
int len = dr.GetInt32(1);
data = new byte[len];
dr.GetBytes(0, 0, data, 0, data.Length);
}
}
}
using (FileStream fs = new FileStream(destFilePath, FileMode.Create,
FileAccess.Write, FileShare.Write))
{
fs.Write(data, 0, data.Length);
}
}
public void WriteFromFileToDB(string sourceFilePath)
{
byte[] data;
using (FileStream fs = new FileStream(sourceFilePath, FileMode.Open,
FileAccess.Read, FileShare.Read))
{
data = new byte[fs.Length];
fs.Read(data, 0, (int)fs.Length);
}
using (SqlConnection conn = new SqlConnection(connStr))
{
StringBuilder sb = new StringBuilder();
sb.Append("Update dbo.TableName");
sb.AppendFormat("\nSet Content = @.Content");
sb.AppendFormat("\nWhere PK= @.PK");
conn.Open();
using (SqlCommand cmd = new SqlCommand(sb.ToString(), conn))
{
cmd.CommandType = CommandType.Text;
cmd.Parameters.Add("@.Content", SqlDbType.Image);
cmd.Parameters.Add("@.PK", SqlDbType...
cmd.Parameters[0].Value = data;
cmd.Parameters[1].Value = <pk>
cmd.ExecuteNonQuery();
}
}
}
I used a dynamic SQL statement, but you could just as easily use a stored pr
oc.
HTH
Thomas
"Sathian" <sathian.t@.in.bosch.com> wrote in message
news:d3nfqc$oem$1@.ns2.fe.internet.bosch.com...
> Hello thomas,
> Thank you very much.
> Any sample piece of code wiich does so..?
> I tried in net.. so far I wasn't sucessful..
> Regards
> Sathian
> "Thomas" <thomas@.newsgroup.nospam> wrote in message
> news:eoguWJXQFHA.2876@.TK2MSFTNGP09.phx.gbl...
> more
> contents
>
Showing posts with label friends. Show all posts
Showing posts with label friends. Show all posts
Wednesday, March 21, 2012
Monday, March 12, 2012
IList as DataSource (NHibernate usage)
Hi Friends,
It is possible to use IList as Data Source in the Reporting Services? I am
using NHibernate for access the data.
Thanks,
Pedro.You would need to write a custom DataExtension that can consume your
DAL.
It is possible to use IList as Data Source in the Reporting Services? I am
using NHibernate for access the data.
Thanks,
Pedro.You would need to write a custom DataExtension that can consume your
DAL.
Wednesday, March 7, 2012
IIS 4 Hangs to SQL 2000
Hello everyone,
I've done some searching, asking of friends, and searching every log file and event file I can think of. So now I'm coming here.
Recently I moved some of our databases from an NT4 box running SQL 7 to an Advanced 2000 box running SQL 2000. The web server is still on an NT4 box. It seems that about three times a day or so ASP type files will hang on the webserver. This server hosts different sites and all ASP type files will stop even if some of them hit the old SQL7 server.
Right now I moved the web server back to looking at the SQL 7 machine and things are going fine.
Can anyone offer me a direction to start looking? Why is it working fine to the old stuff but not the new stuff? Is there an issue with NT4 with its IIS trying to talk to an Advanced 2000 with its SQL2000?
Thank you in advance for any help.Are you getting any logs in the event logs when this happens? Are you using ADO to connect to both boxes (7.0 and 2000)? What version is your MDAC or connection dll's at?|||All three MDACs are at 2.6. I say three because of the old SQL7, new SQL2000, and the webserver.
It is using DSN connection on some items. There is one item that I'm not sure of because I didn't code it. Some time ago one of my managers (not with us any more) wrote our Content Managment Assistant (CMA). It is a Java com object. He created it so it gets the server, user, and password information from a registry key.
Just a bit more information, ever since I changed the webserver to go back to the old SQL7 machine there have been no problems. I will gladly get you any more information that might help, but I may need a little more info on finding it, for example, which DLLs in question are you wanting me to check?
Thank you again.
I've done some searching, asking of friends, and searching every log file and event file I can think of. So now I'm coming here.
Recently I moved some of our databases from an NT4 box running SQL 7 to an Advanced 2000 box running SQL 2000. The web server is still on an NT4 box. It seems that about three times a day or so ASP type files will hang on the webserver. This server hosts different sites and all ASP type files will stop even if some of them hit the old SQL7 server.
Right now I moved the web server back to looking at the SQL 7 machine and things are going fine.
Can anyone offer me a direction to start looking? Why is it working fine to the old stuff but not the new stuff? Is there an issue with NT4 with its IIS trying to talk to an Advanced 2000 with its SQL2000?
Thank you in advance for any help.Are you getting any logs in the event logs when this happens? Are you using ADO to connect to both boxes (7.0 and 2000)? What version is your MDAC or connection dll's at?|||All three MDACs are at 2.6. I say three because of the old SQL7, new SQL2000, and the webserver.
It is using DSN connection on some items. There is one item that I'm not sure of because I didn't code it. Some time ago one of my managers (not with us any more) wrote our Content Managment Assistant (CMA). It is a Java com object. He created it so it gets the server, user, and password information from a registry key.
Just a bit more information, ever since I changed the webserver to go back to the old SQL7 machine there have been no problems. I will gladly get you any more information that might help, but I may need a little more info on finding it, for example, which DLLs in question are you wanting me to check?
Thank you again.
Subscribe to:
Posts (Atom)