Showing posts with label file. Show all posts
Showing posts with label file. Show all posts

Friday, March 30, 2012

Newbie question on physical file last mod date vs. virtual DB/Log

I think I understand the basic features of log files and how to
backup/truncate them to avoid oversized files. Where I need
help is understanding why the O/S rarely puts a new datetime
on the physical files. It appears to only update the log file
time when the log file grows. The DB file may go a month or more
without updating the timestamp. Our backups of the DB grow in
size and appear to be OK. CHECKPOINT commands don't force
the physical disk to update. Is there any other way to do it
(short of drastic measures like detaching the DB)?
Here's my concern: Suppose the server crashes due to a power
failure/UPS failure/whatever. When it restarts it will look at the
log to recover the DB. The physical DB file appears to be a month old
and the log datetime appears to be a day or two old.
If I truncated my log at any time in the last month then it seems like
it will not be able to recover correctly.
Is this really a problem or is it OK?
Environment: SQL Server 2000 on Win2K ServerWhy and when Windows updates the datetime for the file, I don't know. Perhaps somebody in the
windows forum can answer that. However:
> Here's my concern: Suppose the server crashes due to a power
> failure/UPS failure/whatever. When it restarts it will look at the
> log to recover the DB.
Correct. SQL Server know where to find the ldf file, it is stored both in the mdf file as well as in
the master database.
> The physical DB file appears to be a month old
Doesn't matter to SQL Server.
> and the log datetime appears to be a day or two old.
Can you explain what you mean by "log datetime"?
> If I truncated my log at any time in the last month then it seems like
> it will not be able to recover correctly.
What do you mean by "truncated"? Something like BACKUP LOG ... WITH TRUNCATE_ONLY? As long as you
haven't deleted the log file and replaced with an older version, you are fine. SQL server will not
remove log records needed to do recovery of the database.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Don Anthony" <DonAnthony@.discussions.microsoft.com> wrote in message
news:0817C2B3-1F18-4B50-A4C8-6A54D52D0D87@.microsoft.com...
>I think I understand the basic features of log files and how to
> backup/truncate them to avoid oversized files. Where I need
> help is understanding why the O/S rarely puts a new datetime
> on the physical files. It appears to only update the log file
> time when the log file grows. The DB file may go a month or more
> without updating the timestamp. Our backups of the DB grow in
> size and appear to be OK. CHECKPOINT commands don't force
> the physical disk to update. Is there any other way to do it
> (short of drastic measures like detaching the DB)?
> Here's my concern: Suppose the server crashes due to a power
> failure/UPS failure/whatever. When it restarts it will look at the
> log to recover the DB. The physical DB file appears to be a month old
> and the log datetime appears to be a day or two old.
> If I truncated my log at any time in the last month then it seems like
> it will not be able to recover correctly.
> Is this really a problem or is it OK?
> Environment: SQL Server 2000 on Win2K Server
>|||Re: Can you explain what you mean by "log datetime"?
Answer: The last modification time on the log file (i.e, both
the DB file and the Log file appear to be "old" on the disk).
Re: What do you mean by "truncated"?
Something like BACKUP LOG ... WITH TRUNCATE_ONLY?
Answer: Yes.
If the log file had a recent last modification time (the Windows File)
then it all makes sense. It seems like "magic" because it "looks" like
SQL Server does recovery with an very old DB file and a not-so-recent
Log file. Is it possible the disk files are actually updated by SQL
Server without changing the disk file last modification time?
Thank you for your help.|||> Is it possible the disk files are actually updated by SQL
> Server without changing the disk file last modification time?
Yes, this is what is happening. Again, check with the Windows people under what conditions the NTFS
file timestamps are changed. I understand that you find this ... interesting, but just don't worry
about the file timestamps.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Don Anthony" <DonAnthony@.discussions.microsoft.com> wrote in message
news:898EB1A4-A02E-456F-B82A-4391608EAD6A@.microsoft.com...
> Re: Can you explain what you mean by "log datetime"?
> Answer: The last modification time on the log file (i.e, both
> the DB file and the Log file appear to be "old" on the disk).
> Re: What do you mean by "truncated"?
> Something like BACKUP LOG ... WITH TRUNCATE_ONLY?
> Answer: Yes.
> If the log file had a recent last modification time (the Windows File)
> then it all makes sense. It seems like "magic" because it "looks" like
> SQL Server does recovery with an very old DB file and a not-so-recent
> Log file. Is it possible the disk files are actually updated by SQL
> Server without changing the disk file last modification time?
> Thank you for your help.
>|||Don Anthony wrote:
> Re: Can you explain what you mean by "log datetime"?
> Answer: The last modification time on the log file (i.e, both
> the DB file and the Log file appear to be "old" on the disk).
> Re: What do you mean by "truncated"?
> Something like BACKUP LOG ... WITH TRUNCATE_ONLY?
> Answer: Yes.
> If the log file had a recent last modification time (the Windows File)
> then it all makes sense. It seems like "magic" because it "looks" like
> SQL Server does recovery with an very old DB file and a not-so-recent
> Log file. Is it possible the disk files are actually updated by SQL
> Server without changing the disk file last modification time?
> Thank you for your help.
>
I'm not sure, but I'd think that the file timestamp for the logfile and
database file are only updated when the files are actually changed. That
could e.g. be when the file grows or shrinks.
I've just looked at one of our databases, and here the date for the
database file is 26. febr. 2006 and for the logfile it's 3. jan. 2006.
Like Tibors says, SQL server isn't using these file timestamps for
anything, so help yourself and don't worry about them...:-).
Regards
Steen

Newbie question on BULK INSERT of text file

A non-SQL application appends messages to a plain text file.
I want to read the rows of this text file into a table.
The text is in a general format and should be considered one column.
The lines are terminated with a typical CR/LF.
I'd like to do more analysis on the text after getting it into a table.
My Problem: BULK INSERT will skip every other line
with the code below. It seems to take the CR/LF as a column
terminator and then skip over the next row to the new CR/LF
to consider the row to be complete.
How do I get rows of plain text from a text file to a table?
Create Table #MyTempFile ( FileLine varchar(250) )
BULK INSERT #MyTempFile
FROM 'MyTextFile.txt'
WITH
(
BATCHSIZE = 50,
DATAFILETYPE = 'char',
FIELDTERMINATOR = '\r',
ROWTERMINATOR = '\n'
)try taking out the field terminator parameter and make the row teminator the
combined "\r\n" instead.
If that fails, It's possible you might have to use "\n\r".
"Don Anthony" wrote:

> A non-SQL application appends messages to a plain text file.
> I want to read the rows of this text file into a table.
> The text is in a general format and should be considered one column.
> The lines are terminated with a typical CR/LF.
> I'd like to do more analysis on the text after getting it into a table.
> My Problem: BULK INSERT will skip every other line
> with the code below. It seems to take the CR/LF as a column
> terminator and then skip over the next row to the new CR/LF
> to consider the row to be complete.
> How do I get rows of plain text from a text file to a table?
> Create Table #MyTempFile ( FileLine varchar(250) )
> BULK INSERT #MyTempFile
> FROM 'MyTextFile.txt'
> WITH
> (
> BATCHSIZE = 50,
> DATAFILETYPE = 'char',
> FIELDTERMINATOR = '\r',
> ROWTERMINATOR = '\n'
> )
>|||When I take out the FIELDTERMINATOR line I get the error show below
(tried various combinations of ROWTERMINATOR but get the same error).
Server: Msg 4866, Level 17, State 66, Line 1
Bulk Insert fails. Column is too long in the data file for row 1, column 1.
Make sure the field terminator and row terminator are specified correctly.
Server: Msg 7399, Level 16, State 1, Line 1
OLE DB provider 'STREAM' reported an error. The provider did not give any
information about the error.
OLE DB error trace [OLE/DB Provider 'STREAM' IRowset::GetNextRows returned
0x80004005: The provider did not give any information about the error.].
The statement has been terminated.|||You're right. My mistake. But I did get two different versions of bulk
insert ot work
including your original code. Are you sure there are no other stray
caharacters at the end of the lines other than Cr/LF? If you have a text
editor, check the hex display to make sure. Also, is it possible there are
data lines that are more than 250 bytes? Your table definition allows for
varchar(250).
This worked for me:
Create Table #MyTempFile ( FileLine varchar(250) )
BULK INSERT #MyTempFile
FROM 'e:\state_calls\texttest.txt'
WITH
(
BATCHSIZE = 50,
DATAFILETYPE = 'char',
fieldterminator = '\r',
ROWTERMINATOR = '\n'
)
Textest.txt contains for records each with cr/lf line terminator:
1234567890
0987654321
abcdefghij
wxyzabcdef
This version worked too:
BULK INSERT #MyTempFile
FROM 'e:\state_calls\texttest.txt'
WITH
(
BATCHSIZE = 50,
DATAFILETYPE = 'char',
fieldterminator = '\r\n'
)
"Don Anthony" wrote:

> When I take out the FIELDTERMINATOR line I get the error show below
> (tried various combinations of ROWTERMINATOR but get the same error).
> Server: Msg 4866, Level 17, State 66, Line 1
> Bulk Insert fails. Column is too long in the data file for row 1, column 1
.
> Make sure the field terminator and row terminator are specified correctly.
> Server: Msg 7399, Level 16, State 1, Line 1
> OLE DB provider 'STREAM' reported an error. The provider did not give any
> information about the error.
> OLE DB error trace [OLE/DB Provider 'STREAM' IRowset::GetNextRows returned
> 0x80004005: The provider did not give any information about the error.].
> The statement has been terminated.
>|||Your code works perfectly.
My code wasn't working because it wasn't quite what I originally indicated
(I did say I was a newbie...)
The real table definition was
CREATE TABLE #MyTempTable ( FileLine varchar(250), RowID int IDENTITY(1, 1)
)
not
CREATE TABLE #MyTempTable ( FileLine varchar(250) )
The bulk insert apparently threw away every other line after
failing to fit it into the identity column.
Everything works fine after I take out the extra column.
Thanks for your help.
"tthrone" wrote:sql

newbie question insert photos in sql 2k

Hello,
I am interested on how to insert a .jpg file into sql server 2k. Does
anyone have an example of this? I would greatly appreciate it.
Jakejake wrote:
> Hello,
> I am interested on how to insert a .jpg file into sql server 2k.
> Does anyone have an example of this? I would greatly appreciate it.
There are many approaches, but you might want to see:
HOWTO: Access and Modify SQL Server BLOB Data by Using the ADO Stream Object
http://support.microsoft.com/defaul...b;en-us;Q258038
FileToBlob - Loading a file into a SQL Server's BLOB
http://www.devx.com/vb2themax/Tip/19669
sincerely,
--
Sebastian K. Zaklada
Skilled Software
http://www.skilledsoftware.com
This posting is provided "AS IS" with no warranties, and confers no rights.

Newbie question for SQL Server System Integration Services Flat File Import

I am new to SSIS...

I have a very simple package that has a flat file source object and an ole db destination object in the data flow. All works fine.

If I change a row in the flat file to make it fail how do I make the program continue and go to the next row?

The ole db destination does not have a Error Output properties like the flat file source does.

Thanks

Check the Properties of the Data Flow Task (or other task you're using for dealing with the flat file) in the Control Flow tab, there is an attribute MaximumErrorCount, which is default to 1.

Monday, March 26, 2012

Newbie question - how do I specify a variable for the file location when using the Execute Packa

There are two options to specify the subpackage location (SQL Server or file location). I'd like to know how I can specify a variable name that points to the file location so I avoid hard coding the file location which could change during production installation.
thanks

This is a start.
http://sqljunkies.com/WebLog/knight_reign/archive/2005/11/12/17375.aspx
Thanks,
K|||

To do this you must work on the file connection manager not on the task.

You go and add a property expression to Expression colection of the CM that would map your variable to the ConnectionString property of the CM.

Thanks,
Ovidiu

|||

Hi, I'm another newbie.

Can you give a short example of how to do that?

Thanks,

Roger

|||

Hi Ovidu,

Thanks for the reply. Yes, I am working in the connection manager. The problem I'm having is getting the connectionstring property to recognize a string variable. I've played with it a lot and the only syntx that I've tried that doesn't cause an error on entry is @.MyVariable. but, when I run the package, it is interpreted as a file name, which it doesn't find.

Tha variable is in scope. When I substitute a script task with a msgbox, I can step through the files. Can you show me a short example of how you'd do it?

Thanks, again,

Roger

Newbie question - how do I specify a variable for the file location when using the Execute Packa

There are two options to specify the subpackage location (SQL Server or file location). I'd like to know how I can specify a variable name that points to the file location so I avoid hard coding the file location which could change during production installation.
thanks

This is a start.
http://sqljunkies.com/WebLog/knight_reign/archive/2005/11/12/17375.aspx
Thanks,
K|||

To do this you must work on the file connection manager not on the task.

You go and add a property expression to Expression colection of the CM that would map your variable to the ConnectionString property of the CM.

Thanks,
Ovidiu

|||

Hi, I'm another newbie.

Can you give a short example of how to do that?

Thanks,

Roger

|||

Hi Ovidu,

Thanks for the reply. Yes, I am working in the connection manager. The problem I'm having is getting the connectionstring property to recognize a string variable. I've played with it a lot and the only syntx that I've tried that doesn't cause an error on entry is @.MyVariable. but, when I run the package, it is interpreted as a file name, which it doesn't find.

Tha variable is in scope. When I substitute a script task with a msgbox, I can step through the files. Can you show me a short example of how you'd do it?

Thanks, again,

Roger

sql

Wednesday, March 21, 2012

Newbie Print Layout problem

When I export a file to any medium (PDF/Excel) I try, the layout is not the
same as what the layout is in the Layout tab.
There's a whole lot of space between the columns, so they don't all fit on
the page (Portrait style), therefore, the PDFs and Excel sheets are way off
Any hints here that I can use to make the print layout look like what I
design in the Layout Tab of the Reporting Services 2005 Design Area?On Jan 8, 11:03 am, "Elmo Watson" <s...@.here.com> wrote:
> When I export a file to any medium (PDF/Excel) I try, the layout is not the
> same as what the layout is in the Layout tab.
> There's a whole lot of space between the columns, so they don't all fit on
> the page (Portrait style), therefore, the PDFs and Excel sheets are way off
> Any hints here that I can use to make the print layout look like what I
> design in the Layout Tab of the Reporting Services 2005 Design Area?
You should be able to start here.
Layout tab >> Report drop-down >> Report Properties... >> Layout tab.
If this does not compact the report enough, you could try putting
multiple report controls (i.e., table control(s), matrix control(s),
textbox(es), etc) into a rectangle. Hope this helps.
Regards,
Enrique Martinez
Sr. Software Consultant

Monday, March 19, 2012

newbie on SQL Server needs some direction .adp and .mde

I'm trying to figure out what is going on. I have an .adp file that has a
connection DNS to a .mde file on the network. It is confusing. In the
connection dialog it has my computer as the server name and it has the
database I am using to connect to the database I want. How can I find out
what is the DNS database source? It seems like it is connected to itself
instead of the right DNS. I don't see any tables in tables but I do get a
list of queries on the server so it must be connected but why don't I see the
tables as well? This is the one I would like to use but I don't get the
world icons that show the real SQL server data. In fact I don't even see the
tables on the access .mde file.
I try to view some queries and I get the error message "ADO error: MSDTC
on Server 'myComputer' is not available. I have MS SQL Server running in
Services as well as SQL Server express. Mainly because I don't know which one
is best. I also get the error 'Ole DB error trace Ole 10B Profvider MS Jet
OlebDB 4.0 Open rowset returned ox.... The specified table does not exist'
which I think means the query cannot access the tables. Why can I get the
queries and not the tables?
If I access it through terminal server access frontend I can make changes to
the queries. I also can see the tables which include dbo tables on a Server
but I would rather write my queries on my own desktop version and not do
anything on the terminal services version.
On the terminal services .mde database there are some pass through queries.
In fact the one I think I need appear to be a pass through query. If I open
the query the data is 2 years old. Can I make a make table from the pass
through query to see if it updates the data? I really do not want to do
anything wrong to the frontend db on terminal services but I need to write
this one query for a report.
tia,DNS are only a name given to a connection string. You don't have to use a
DSN to connect to a SQL-Server; it's only one possibility amongst others.
Second, DNS are only for ODBC while ADP use only ADO. So, you cannot use a
DSN with ADP and even with ADO, ADP can connect only to a SQL-Server and not
to a MDB or a MDE file. Also, the fact that you can connect to a sql-server
doesn't mean that you will be able to see everything (tables, views, sp,
functions, etc.) on the server because of permission issues.
Looks like that you have copied an ADP file from a terminal server to a
local machine but that the permissions on the server are set to block you
from accessing the data from outside the forms in the ADP project or
something like that.
--
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail: sylvain aei ca (fill the blanks, no spam please)
"Janis" <Janis@.discussions.microsoft.com> wrote in message
news:7333903F-5E59-4DF0-8BAB-5C45137AF7A5@.microsoft.com...
> I'm trying to figure out what is going on. I have an .adp file that has a
> connection DNS to a .mde file on the network. It is confusing. In the
> connection dialog it has my computer as the server name and it has the
> database I am using to connect to the database I want. How can I find out
> what is the DNS database source? It seems like it is connected to itself
> instead of the right DNS. I don't see any tables in tables but I do get a
> list of queries on the server so it must be connected but why don't I see
> the
> tables as well? This is the one I would like to use but I don't get the
> world icons that show the real SQL server data. In fact I don't even see
> the
> tables on the access .mde file.
> I try to view some queries and I get the error message "ADO error: MSDTC
> on Server 'myComputer' is not available. I have MS SQL Server running in
> Services as well as SQL Server express. Mainly because I don't know which
> one
> is best. I also get the error 'Ole DB error trace Ole 10B Profvider MS
> Jet
> OlebDB 4.0 Open rowset returned ox.... The specified table does not
> exist'
> which I think means the query cannot access the tables. Why can I get the
> queries and not the tables?
>
> If I access it through terminal server access frontend I can make changes
> to
> the queries. I also can see the tables which include dbo tables on a
> Server
> but I would rather write my queries on my own desktop version and not do
> anything on the terminal services version.
> On the terminal services .mde database there are some pass through
> queries.
> In fact the one I think I need appear to be a pass through query. If I
> open
> the query the data is 2 years old. Can I make a make table from the pass
> through query to see if it updates the data? I really do not want to do
> anything wrong to the frontend db on terminal services but I need to write
> this one query for a report.
> tia,

Newbie needing help -> poll a folder for new files

I need to create a SQLNS app to poll a particular folder for mpeg files. When a new file (which in this case will be an mpeg video file) is dopped into the folder, I need to write some of the files metadata (filename, size, path) to an existing SQL database on the same server. I'd also like to send out an e-mail notifying that an end-user that a record was added to the database.

The subscription piece (e-mail notification) seems easy enough. I'm curious about the implementation of inserting the file metadata into the database. I'm pretty new to SQLNS, so any help to point me in the right direction would be most appreciated.

Thanks in advance!

Hi -

If it were me, I'd probably investigate the following design. I'd create a Windows Service to watch the selected folder for the presence of new mpeg files. When one is discovered, I'd insert a row with the file's metadata into the SQL Server table.

Now for the SQLNS part. I'd create an instance/application that uses the SQL Server Event Provider to watch the SQL Server table mentioned above for the presence of a new row. Subscribers could create subscriptions based on whatever criteria you'd like to put in place (filesize, name, genre, etc).

Make sense?

Could all this be done within SQLNS? Sure, you could create a custom event provider to watch the folder, insert the metadata row, and then insert the event data.

Either would work....but for some reason I tend to prefer the separation afforded by the first solution.

HTH...

Joe

|||Sounds like a great idea! Thanks for your help!! :-D

Monday, March 12, 2012

Newbie Help

Looking to create a flat file from a stored proc that is comma delim.. can
this be done? I know I can use DTS but the table is a temp table and that
wont work.
Thanks for your help in advance.
--
Austin Henderson <><
Network AdministratorYou can shell out to bcp via xp_cmdshell but will have to use a global temp
table (##) as bcp will create it's own connection and your local temp table
would not be visible to it.
--
HTH
Jasper Smith (SQL Server MVP)
I support PASS - the definitive, global
community for SQL Server professionals -
http://www.sqlpass.org
"Austin Henderson" <kahenderson@.firstfleetinc.NOSPAM.com> wrote in message
news:uQpnrkbcDHA.384@.TK2MSFTNGP12.phx.gbl...
Looking to create a flat file from a stored proc that is comma delim.. can
this be done? I know I can use DTS but the table is a temp table and that
wont work.
Thanks for your help in advance.
--
Austin Henderson <><
Network Administrator

Friday, March 9, 2012

newbie has questions...

SQL Server 7.00.623

1. Am I correct in assuming that the initialization parameters that Oracle places in a init.ora file are handled in SQL Server using registry keys? BOL describes how to create a user-defined configuration file based on the setup.iss file, but is this only for unattended installs?

2. With the version of SQL Server that I'm running, is there any reason for me to use isql at all, as opposed to osql? Is isql bundled with 7 simply to be backward compatable with 6.5, or am I missing something here? BOL mentions that isql does not support some of 7's features, otherwise are they the same utility?

3. Generally speaking, should SQL Server be left alone to dynamically manage memory, or should the db be initialized with pre-allocated memory? From what I've been able to gather on the Web (I've only been at this SQL Server stuff for 3 days now...), it seems it does a pretty good job of this itself. Any thoughts?

4. Also, with respect to the physical implementation of SQL Server, if anyone could briefly explain the similarities/differences between SQL Server's Transaction Log and Oracle's redo logs, that would be great. (for example, in SQL Server, if there is only one log, how does the db engine manage the completion/continuation of transactions during a chkpt...am I correct in assuming that there are multiple 'logs' within the one transaction log?). Any thoughts would be helpful...

Cheers,
Chris1. Probably - also called statrtup parameters and can be set in enterprise manager.

2. Yes - isql no longer used.

3. Leave it to manage memory itself unless it causes problems.

4. Every time an update is made entries are put in the log. It is just a circular table. The entries are marked as inactive when the transaction is committed and checkpointed. Several spids can be writing entries at the same time and these will be interleaved.

Get a copy of inside sql server 2000.
Even if you use v7 it's probably worth getting this as the database engine is mostly the same - just watch out for new features.|||more info..

1. Yes, you are correct. The start up parms can be set in EM and are stored in registry. You can start the server via the command line and override the startup parms in the registry.

2. The diffrence between isql and oslq are how they connect to the db. isql uses an older method DB-LIB while osql uses ODBC (OLE DB). You will find that your connection defaults are diffrent between the two, Books Online covers this rather well. In my shop We hve old code the uses DB-LIB to connect as well as OLE DB. When I change stored procedures I run unit tests through both types of connections.

3. I agree %110

4. can't add anything more.|||Thanks, fellas...

With respect to the Transaction Log, I'm beginning to think of it as a kind of hybrid of Oracle's Redo Logs and Rollback Segment. It seems to handle both logging and transactional activity. I'm sure it will all become clear either sooner or later...

Anyways, I was going to add in my first post, 'Please no reply that I RTFM...'. Sad, but true, there are no books available on this island that I've been able to find...

Cheers...|||IMHO, One of the first places you should look for answers is Microsoft's Books Online shipped with SQL Server aka TFM in RTFM. This is one of the best documents I have seen if you have some knowledge of SQL Server or RDBs. The second place to look is www.Google.com. Between the two I am rarely stumped for an answer.|||Paul -

I read you loud and clear, and agree with you completely. BOL is excellent, and of course Google is my very basic resource. I've been thrown into both Informix and SQL Server recently, and between the two I've been forced to forget that Utopia called Metalink. With respect to SQL Server, the forgetting shouldn't be too painful...

newbie confusion: file vs server

caution: this is not doubt a stupid newbie question... Smile

In creating vs.net 2005 website, I can add a sql database to my project and a mdf file is created. I can create data providers against this file, etc, just as though it were a database in a sql server instance. I can deploy this dbf file to my finished web site.

Also, I can attach to a running instance of sql server 2005 express, and do exactly the same thing.

I can also take my mdf file created in step 1 above, and attach it to a running instance of sql server express.

Now, I have delt with access databases, and sql server 2000 databases, so this dual nature of sql server 2005 express confuses me a little.

Why would I ever need to use a server instance of sql server 2005 when I can use a file based data file in my web apps? Is there an advantage to one or the other?

I had a thought that when using the file based method, I was actually still using the server based stuff, which would explain why the sql server express notification bubble pops up when I debug on the dev machine.

In any case could someone explain the difference and should I install sql server 2005 express on my deployment server?

thanks.

Access is a database SQL Server Express is a SQL Server 2005 edition which is RDBMS(relational database management systems) without a SQL Server instance you don't have a database engine to run your MDF(Microsoft data file) it is just one of at least two files you need to run your database. Run a search for file groups in SQL Server BOL(books online). Hope this helps.

http://msdn2.microsoft.com/en-us/library/ms179316.aspx

|||

In order to use a *.mdf (SQL Server database file), you must have a SQL Server installed and running.

That could be SQL Server 2005 Express.

|||

Thanks for the replies. I have a clearer picture but have some additional questions...

I add a mdf file to my asp.net website. This file requires some version of SQL server, in this case

Express, to provide the RDMS system. Great. So how is it that I can just deploy the app to the web server

and it works without installing SQL server Express on the web server?

Is SQL Server Express built into the ASP.Net 2.0 runtime?

If so, the file must somehow be dynamically attached to this instance of SQL Server Express?

How will this type of deployment be upgraded to a higher version of SQL Server? If I use the "file" based

technique, will my app always use the embeded SQL Server Express and not any fuller version of SQL Server

I may install?

So to migrate to a higher version of SQL Server, will I need to attach the mdf file to SQL Server and change my

connection string to point to the new version of SQL Server?

This is my last little stumbling block to grasping the SQL Server Express concept, thanks for your replies!

|||

Perhaps this will clear some things up for you.

http://msdn2.microsoft.com/en-us/library/bb264564.aspx

|||

yes, perfect. Thanks.

No doubt I over think these things.

While I appreciate the ease of use, I also like knowing what's going on, so the documentation is there, of course, but in such great volume one questions the point of reading massive amounts of documentation on an easy to use feature. ;-) I digress...thanks again.

Newbie Cant connect - Trusted Server issue.

Hello,

I'm creating an application that will rely on a central SQL Server database
for its help file. I'm a beginner with SQL Server really, and I keep
getting the following error;

"Login failed for use 'whateverUser'. Reason: Not associated with a trusted
SQL Server connection"

I can't seem to find a solution in the help files. Any direction would be
greatly appreciated.

Thanks!Jozef (SPAM_O_NATOR@.telus.net) writes:
> I'm creating an application that will rely on a central SQL Server
> database for its help file. I'm a beginner with SQL Server really, and
> I keep getting the following error;
> "Login failed for use 'whateverUser'. Reason: Not associated with a
> trusted SQL Server connection"
> I can't seem to find a solution in the help files. Any direction would be
> greatly appreciated.

You can log into SQL Server in two ways: Windows authentication, and
SQL Server authentication. The former is always available, for SQL Server
authentication to be available, the server must be enabled for this,
which by default it is not.

With Windows authentication, SQL Server accepts your Windows user,
if it has been granted access to SQL Server, and if SQL Server can
somehow validate it. With SQL Server authentication, you provide a
username and password that SQL Server itself validates.

Windows authentication is generally more secure, and also more convient,
since it does not require any extra username/password. However, it does
not always work well, if user and server are not in the same domain -
including when there is no domain at all.

Since you replaced the actual username with 'whateverUser', I don't know
which form of authentication you are trying to use. But if you are not
using Windows authentication, I recommend that you switch to this, by
replacing UserID and Password in the connection string with
Trusted_connection=Yes.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Thanks Erland, that's the most definitive answer I've been able to find.
I'd like to use Windows authentication if I can but this has given me enough
info to be able to play with both.

Thanks again!

"Erland Sommarskog" <esquel@.sommarskog.se> wrote in message
news:Xns9679C13AF3F52Yazorman@.127.0.0.1...
> Jozef (SPAM_O_NATOR@.telus.net) writes:
>> I'm creating an application that will rely on a central SQL Server
>> database for its help file. I'm a beginner with SQL Server really, and
>> I keep getting the following error;
>>
>> "Login failed for use 'whateverUser'. Reason: Not associated with a
>> trusted SQL Server connection"
>>
>> I can't seem to find a solution in the help files. Any direction would
>> be
>> greatly appreciated.
> You can log into SQL Server in two ways: Windows authentication, and
> SQL Server authentication. The former is always available, for SQL Server
> authentication to be available, the server must be enabled for this,
> which by default it is not.
> With Windows authentication, SQL Server accepts your Windows user,
> if it has been granted access to SQL Server, and if SQL Server can
> somehow validate it. With SQL Server authentication, you provide a
> username and password that SQL Server itself validates.
> Windows authentication is generally more secure, and also more convient,
> since it does not require any extra username/password. However, it does
> not always work well, if user and server are not in the same domain -
> including when there is no domain at all.
> Since you replaced the actual username with 'whateverUser', I don't know
> which form of authentication you are trying to use. But if you are not
> using Windows authentication, I recommend that you switch to this, by
> replacing UserID and Password in the connection string with
> Trusted_connection=Yes.
>
> --
> Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
> Books Online for SQL Server SP3 at
> http://www.microsoft.com/sql/techin.../2000/books.asp

Newbie Can't connect - Trusted Server issue.

Hello,
I'm creating an application that will rely on a central SQL Server database
for its help file. I'm a beginner with SQL Server really, and I keep
getting the following error;
"Login failed for use 'whateverUser'. Reason: Not associated with a trusted
SQL Server connection"
I can't seem to find a solution in the help files. Any direction would be
greatly appreciated.
Thanks!
Jozef (SPAM_O_NATOR@.telus.net) writes:
> I'm creating an application that will rely on a central SQL Server
> database for its help file. I'm a beginner with SQL Server really, and
> I keep getting the following error;
> "Login failed for use 'whateverUser'. Reason: Not associated with a
> trusted SQL Server connection"
> I can't seem to find a solution in the help files. Any direction would be
> greatly appreciated.
You can log into SQL Server in two ways: Windows authentication, and
SQL Server authentication. The former is always available, for SQL Server
authentication to be available, the server must be enabled for this,
which by default it is not.
With Windows authentication, SQL Server accepts your Windows user,
if it has been granted access to SQL Server, and if SQL Server can
somehow validate it. With SQL Server authentication, you provide a
username and password that SQL Server itself validates.
Windows authentication is generally more secure, and also more convient,
since it does not require any extra username/password. However, it does
not always work well, if user and server are not in the same domain -
including when there is no domain at all.
Since you replaced the actual username with 'whateverUser', I don't know
which form of authentication you are trying to use. But if you are not
using Windows authentication, I recommend that you switch to this, by
replacing UserID and Password in the connection string with
Trusted_connection=Yes.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
|||You also might want to verify the connection string you are using is
completely correct. http://www.connectionstrings.com has a good collection
of all the various formats to use.
If you're just getting started in programming, you also might want to check
out www.asp.net and www.devx.com. They have some great articles and samples
to get you started, in addition to books, etc.
MeanOldDBA
derrickleggett@.hotmail.com
http://weblogs.sqlteam.com/derrickl
When life gives you a lemon, fire the DBA.
"Erland Sommarskog" wrote:

> Jozef (SPAM_O_NATOR@.telus.net) writes:
> You can log into SQL Server in two ways: Windows authentication, and
> SQL Server authentication. The former is always available, for SQL Server
> authentication to be available, the server must be enabled for this,
> which by default it is not.
> With Windows authentication, SQL Server accepts your Windows user,
> if it has been granted access to SQL Server, and if SQL Server can
> somehow validate it. With SQL Server authentication, you provide a
> username and password that SQL Server itself validates.
> Windows authentication is generally more secure, and also more convient,
> since it does not require any extra username/password. However, it does
> not always work well, if user and server are not in the same domain -
> including when there is no domain at all.
> Since you replaced the actual username with 'whateverUser', I don't know
> which form of authentication you are trying to use. But if you are not
> using Windows authentication, I recommend that you switch to this, by
> replacing UserID and Password in the connection string with
> Trusted_connection=Yes.
>
> --
> Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
> Books Online for SQL Server SP3 at
> http://www.microsoft.com/sql/techinf...2000/books.asp
>
|||Thanks Erland, that's the most definitive answer I've been able to find.
I'd like to use Windows authentication if I can but this has given me enough
info to be able to play with both.
Thanks again!
"Erland Sommarskog" <esquel@.sommarskog.se> wrote in message
news:Xns9679C13AF3F52Yazorman@.127.0.0.1...
> Jozef (SPAM_O_NATOR@.telus.net) writes:
> You can log into SQL Server in two ways: Windows authentication, and
> SQL Server authentication. The former is always available, for SQL Server
> authentication to be available, the server must be enabled for this,
> which by default it is not.
> With Windows authentication, SQL Server accepts your Windows user,
> if it has been granted access to SQL Server, and if SQL Server can
> somehow validate it. With SQL Server authentication, you provide a
> username and password that SQL Server itself validates.
> Windows authentication is generally more secure, and also more convient,
> since it does not require any extra username/password. However, it does
> not always work well, if user and server are not in the same domain -
> including when there is no domain at all.
> Since you replaced the actual username with 'whateverUser', I don't know
> which form of authentication you are trying to use. But if you are not
> using Windows authentication, I recommend that you switch to this, by
> replacing UserID and Password in the connection string with
> Trusted_connection=Yes.
>
> --
> Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
> Books Online for SQL Server SP3 at
> http://www.microsoft.com/sql/techinf...2000/books.asp

Newbie Can't connect - Trusted Server issue.

Hello,
I'm creating an application that will rely on a central SQL Server database
for its help file. I'm a beginner with SQL Server really, and I keep
getting the following error;
"Login failed for use 'whateverUser'. Reason: Not associated with a trusted
SQL Server connection"
I can't seem to find a solution in the help files. Any direction would be
greatly appreciated.
Thanks!Jozef (SPAM_O_NATOR@.telus.net) writes:
> I'm creating an application that will rely on a central SQL Server
> database for its help file. I'm a beginner with SQL Server really, and
> I keep getting the following error;
> "Login failed for use 'whateverUser'. Reason: Not associated with a
> trusted SQL Server connection"
> I can't seem to find a solution in the help files. Any direction would be
> greatly appreciated.
You can log into SQL Server in two ways: Windows authentication, and
SQL Server authentication. The former is always available, for SQL Server
authentication to be available, the server must be enabled for this,
which by default it is not.
With Windows authentication, SQL Server accepts your Windows user,
if it has been granted access to SQL Server, and if SQL Server can
somehow validate it. With SQL Server authentication, you provide a
username and password that SQL Server itself validates.
Windows authentication is generally more secure, and also more convient,
since it does not require any extra username/password. However, it does
not always work well, if user and server are not in the same domain -
including when there is no domain at all.
Since you replaced the actual username with 'whateverUser', I don't know
which form of authentication you are trying to use. But if you are not
using Windows authentication, I recommend that you switch to this, by
replacing UserID and Password in the connection string with
Trusted_connection=Yes.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||You also might want to verify the connection string you are using is
completely correct. http://www.connectionstrings.com has a good collection
of all the various formats to use.
If you're just getting started in programming, you also might want to check
out www.asp.net and www.devx.com. They have some great articles and samples
to get you started, in addition to books, etc.
MeanOldDBA
derrickleggett@.hotmail.com
http://weblogs.sqlteam.com/derrickl
When life gives you a lemon, fire the DBA.
"Erland Sommarskog" wrote:

> Jozef (SPAM_O_NATOR@.telus.net) writes:
> You can log into SQL Server in two ways: Windows authentication, and
> SQL Server authentication. The former is always available, for SQL Server
> authentication to be available, the server must be enabled for this,
> which by default it is not.
> With Windows authentication, SQL Server accepts your Windows user,
> if it has been granted access to SQL Server, and if SQL Server can
> somehow validate it. With SQL Server authentication, you provide a
> username and password that SQL Server itself validates.
> Windows authentication is generally more secure, and also more convient,
> since it does not require any extra username/password. However, it does
> not always work well, if user and server are not in the same domain -
> including when there is no domain at all.
> Since you replaced the actual username with 'whateverUser', I don't know
> which form of authentication you are trying to use. But if you are not
> using Windows authentication, I recommend that you switch to this, by
> replacing UserID and Password in the connection string with
> Trusted_connection=Yes.
>
> --
> Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
> Books Online for SQL Server SP3 at
> http://www.microsoft.com/sql/techin.../2000/books.asp
>|||Thanks Erland, that's the most definitive answer I've been able to find.
I'd like to use Windows authentication if I can but this has given me enough
info to be able to play with both.
Thanks again!
"Erland Sommarskog" <esquel@.sommarskog.se> wrote in message
news:Xns9679C13AF3F52Yazorman@.127.0.0.1...
> Jozef (SPAM_O_NATOR@.telus.net) writes:
> You can log into SQL Server in two ways: Windows authentication, and
> SQL Server authentication. The former is always available, for SQL Server
> authentication to be available, the server must be enabled for this,
> which by default it is not.
> With Windows authentication, SQL Server accepts your Windows user,
> if it has been granted access to SQL Server, and if SQL Server can
> somehow validate it. With SQL Server authentication, you provide a
> username and password that SQL Server itself validates.
> Windows authentication is generally more secure, and also more convient,
> since it does not require any extra username/password. However, it does
> not always work well, if user and server are not in the same domain -
> including when there is no domain at all.
> Since you replaced the actual username with 'whateverUser', I don't know
> which form of authentication you are trying to use. But if you are not
> using Windows authentication, I recommend that you switch to this, by
> replacing UserID and Password in the connection string with
> Trusted_connection=Yes.
>
> --
> Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
> Books Online for SQL Server SP3 at
> http://www.microsoft.com/sql/techin.../2000/books.asp

Wednesday, March 7, 2012

Newbie (MAC user) question: What is an SQL database... Or how to

Well this is not really the question... What I actually mean is: Is a SQL
database a file or an ensemble of files which can be developed on a PC, then
if the PC hasn't got a connection to the remote server, be transferred onto
a disk and copied into an SQL DBMS.
My problem is the following. I have decided to start developing web sites
which use ASP.NET and SQL on a Macintosh system. Not the best choice I
know...
My ISP has set up an SQL database which I need to populate with table,
columns and of course data. To do so I have found ASP Enterprise Manager
from the internet (http://www.aspenterprisemanager.com/) which allowed me to
create a table and a few other things, but because of the lack of manual I
am at a lost as to what else it can do and whether there is a better tool to
develop SQL on a Mac. Any suggestion about this would be very welcome.
By the way I have been able to connect to the db with Macromedia Dreamweaver
and I have created a form that loads data in the field. It's great to see it
working...
But to get back to my primary question... If I were to develop the SQL
database on a PC which as I said earlier doesn't have a connection to the
internet (it's an old one, you see), does it create a file, or a set of
files (the database, like an Access database would be a file) which can then
be transported to my Mac via a disk and sent to my ISP to upload in the SQL
DBMS to replace the one I have created with ASP Enterprise Manager.
Hope you make sense of these questions, and that you will come back with a
suggestion or two. Please no suggestion such as dump my Mac and buy a PC...
I love my Mac. I know it makes my life difficult at the moment, but which
relationship doesn't have it's difficult moments?
Merci beaucoup
William"William Lesourd" <william@.francodesign.com> wrote in message
news:BBC5CBC9.5166%william@.francodesign.com...
<snip>
> But to get back to my primary question... If I were to develop the SQL
> database on a PC which as I said earlier doesn't have a connection to the
> internet (it's an old one, you see), does it create a file, or a set of
> files (the database, like an Access database would be a file) which can
then
> be transported to my Mac via a disk and sent to my ISP to upload in the
SQL
> DBMS to replace the one I have created with ASP Enterprise Manager.
William,
Sql does indeed store it's databases in data files (default extension either
.mdf or .ndf) and a log file (.ldf). You would need to get the mdf file to
your ISP, but it is not simply a matter of them copying the file. They need
to attach the file to the database in order to tell SQL server about it.
Probably a better idea is to send them a back-up. In the SQL Server Master
database run the command:
BACKUP DATABASE mybase to file = 'c:\mybackup.bak', then your ISP can
restore it over your old database. (Or maybe your ASP manager can back it
up for you)
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.532 / Virus Database: 326 - Release Date: 27/10/2003|||You could do your development on a different SQL Server than
the one which will eventually host the database (using the
same versions). After you have everything set, you can
either do a backup and then restore to the other SQL Server
or you can use sp_detach_db, copy the database files to the
other location and then reattach them with sp_attach_db.
As a side note and nothing to do with Macs - You can
download SQL Server books online...it might make things
easier for you:
http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp
-Sue
On Wed, 29 Oct 2003 19:55:53 +0000, William Lesourd
<william@.francodesign.com> wrote:
>But to get back to my primary question... If I were to develop the SQL
>database on a PC which as I said earlier doesn't have a connection to the
>internet (it's an old one, you see), does it create a file, or a set of
>files (the database, like an Access database would be a file) which can then
>be transported to my Mac via a disk and sent to my ISP to upload in the SQL
>DBMS to replace the one I have created with ASP Enterprise Manager.

Newbie - Store jpg file in Image Data Type Field

I assume that this is really simple to do once you know how to do it.
I have a very small table, only 5 rows and two columns. Column 0 is
an integer from 1 to 5, and column 1 is supposed to store an image
corresponding to each of the values in column 0. I have the five
different image files in a jpg format. I tried simply copying and
pasting these files into the table, but that didn't work. Can
somebody tell me how to save these jpg files in the table so that I
can use them in my VB.NET application?
Thanks,
RandySQL 2000?
"Randy" <spam.eastland@.gmail.com> wrote in message
news:1182898391.523504.187750@.i38g2000prf.googlegroups.com...
>I assume that this is really simple to do once you know how to do it.
> I have a very small table, only 5 rows and two columns. Column 0 is
> an integer from 1 to 5, and column 1 is supposed to store an image
> corresponding to each of the values in column 0. I have the five
> different image files in a jpg format. I tried simply copying and
> pasting these files into the table, but that didn't work. Can
> somebody tell me how to save these jpg files in the table so that I
> can use them in my VB.NET application?
> Thanks,
> Randy
>|||Actually, SQL Server Management Studio Express|||In SQL Server 2005 you can use OPENROWSET with the SINGLE_BLOB option, like
this:
CREATE TABLE Foobar (
image_data VARBINARY(MAX));
INSERT INTO Foobar
(image_data)
SELECT image_data
FROM OPENROWSET(
BULK N'C:\image.jpg',
SINGLE_BLOB)
AS ImageSource(image_data);
HTH,
Plamen Ratchev
http://www.SQLStudio.com|||Thanks, but I don't know how to implement this. I'd like to actually
store the files within the datatable rather than referencing them from
a file location. Is that possible? Otherwise, can you explain this
to me in further detail?
Thanks again.
Randy|||That will store them in the database, it is insert script. You do it onces
they are there for access. If you want to do it from .NET code.. I don't
have .NET example, but here is example on how to do it in VB6, maybe you can
convert it.
Private Sub InsertFile()
On Error GoTo ErrorHandler
Dim Index As Long
Dim strSQL As String
Dim rs As ADODB.Recordset
Dim mstream As ADODB.Stream
strSQL = "SELECT * FROM TableName"
Set rs = New ADODB.Recordset
rs.Open strSQL, cn, adOpenDynamic, adLockOptimistic
Set mstream = New ADODB.Stream
mstream.Type = adTypeBinary
mstream.Open
mstream.LoadFromFile FileNameToLoadWithFullPath
rs.AddNew
rs.Fields('FileData').Value = mstream.Read
rs.Update
rs.Close
End Sub
Mohit K. Gupta
B.Sc. CS, Minor Japanese
MCTS: SQL Server 2005
"Randy" wrote:

> Thanks, but I don't know how to implement this. I'd like to actually
> store the files within the datatable rather than referencing them from
> a file location. Is that possible? Otherwise, can you explain this
> to me in further detail?
> Thanks again.
> Randy
>|||You just need to run this as a query in SQL Server Management Studio. It
will actually store the image data into the table, the reference to the file
location is needed just to load the images.
Here is a more detailed example that may fit better your case. The code
below creates a table with keys and then updates the image column for each
key (based on your initial post I assume this is what you want to do).
CREATE TABLE Foobar (
keycol INTEGER,
image_data VARBINARY(MAX));
-- Insert the keys.
INSERT INTO Foobar (keycol)
SELECT 1
UNION ALL
SELECT 2
UNION ALL
SELECT 3
UNION ALL
SELECT 4
UNION ALL
SELECT 5;
UPDATE Foobar
SET image_data = (
SELECT image_data
FROM OPENROWSET(
BULK N'C:\image1.jpg',
SINGLE_BLOB)
AS ImageSource(image_data))
WHERE keycol = 1;
UPDATE Foobar
SET image_data = (
SELECT image_data
FROM OPENROWSET(
BULK N'C:\image2.jpg',
SINGLE_BLOB)
AS ImageSource(image_data))
WHERE keycol = 2;
-- Continue to load all images...
SELECT keycol, image_data
FROM Foobar;
DROP TABLE Foobar;
HTH,
Plamen Ratchev
http://www.SQLStudio.com|||Thanks to both of you. I'm working with Plamen's query and got it to
execute successfully, however I'm still not all the way there. A
couple of questions:
1. I can see that the table was created in the Results pane, but I
don't know where this table is actually stored. Of course, the table
is of no use until I can make it part of my db, and I don't see it
listed among the tables in the db. How can I create this table so
that it is a permanent member of my db?
2. In the Results pane, I see a two column table. Column 1 is called
keycol and col 2 is called image_data, as created by the query. There
are five rows, each of which contains an integer value from 1 to 5 in
keycol, also as created by the query. However, the fields in
image_data are blank, at least as viewed through the Results pane.
I'm not sure if the images have actually loaded correctly. To
clarify, I changed the query language to include tha path names for
each of the 5 images that I am trying to import, so I don't think that
is part of the problem.
Thanks a lot for sticking with me on this. I'm sorry that I am so
clueless, but working direclty in SQL Server is completely new to me.
Randy|||Ignore that last reply. Apparently, I wasn't looking at refreshed
view of the db. The table is there, as are both columns. There was
no data in the table, so I added the key column values and just ran
the UPDATE part of the query, which seems to have populated the
image_data values. Now, i just have to figure out how to pull this
onto my VB form. When I look at the table data, it just says <Binary
Data> in each of the fields, so I'm not certain that I have everything
in place just yet. If I have trouble, I'll re-post.
Thanks for everybody's help!
Randy|||"Randy" <spam.eastland@.gmail.com> wrote in message
news:1182979823.310482.88750@.e16g2000pri.googlegroups.com...
> Thanks to both of you. I'm working with Plamen's query and got it to
> execute successfully, however I'm still not all the way there. A
> couple of questions:
> 1. I can see that the table was created in the Results pane, but I
> don't know where this table is actually stored. Of course, the table
> is of no use until I can make it part of my db, and I don't see it
> listed among the tables in the db. How can I create this table so
> that it is a permanent member of my db?
If you just copied my sample query, then at the end of it there is a DROP
TABLE statement. You can comment it out or remove it and then run again to
keep the table. This is the line you need to comment out or remove:
--DROP TABLE Foobar;

> 2. In the Results pane, I see a two column table. Column 1 is called
> keycol and col 2 is called image_data, as created by the query. There
> are five rows, each of which contains an integer value from 1 to 5 in
> keycol, also as created by the query. However, the fields in
> image_data are blank, at least as viewed through the Results pane.
> I'm not sure if the images have actually loaded correctly. To
> clarify, I changed the query language to include tha path names for
> each of the 5 images that I am trying to import, so I don't think that
> is part of the problem.
>
You cannot see the image in the result pane, but rather the binary
representation. If you just right click the table and select Open Table, you
should see something like <Binary data> in the image_data column. If you run
the query and look in Result, you should see something like 0xFFD8... If you
see NULL, then the images were not uploaded successfully. I would suggest to
check the path for the files and if the file names are correct.
HTH,
Plamen Ratchev
http://www.SQLStudio.com

Newbie - Store jpg file in Image Data Type Field

I assume that this is really simple to do once you know how to do it.
I have a very small table, only 5 rows and two columns. Column 0 is
an integer from 1 to 5, and column 1 is supposed to store an image
corresponding to each of the values in column 0. I have the five
different image files in a jpg format. I tried simply copying and
pasting these files into the table, but that didn't work. Can
somebody tell me how to save these jpg files in the table so that I
can use them in my VB.NET application?
Thanks,
Randy
SQL 2000?
"Randy" <spam.eastland@.gmail.com> wrote in message
news:1182898391.523504.187750@.i38g2000prf.googlegr oups.com...
>I assume that this is really simple to do once you know how to do it.
> I have a very small table, only 5 rows and two columns. Column 0 is
> an integer from 1 to 5, and column 1 is supposed to store an image
> corresponding to each of the values in column 0. I have the five
> different image files in a jpg format. I tried simply copying and
> pasting these files into the table, but that didn't work. Can
> somebody tell me how to save these jpg files in the table so that I
> can use them in my VB.NET application?
> Thanks,
> Randy
>
|||Actually, SQL Server Management Studio Express
|||In SQL Server 2005 you can use OPENROWSET with the SINGLE_BLOB option, like
this:
CREATE TABLE Foobar (
image_data VARBINARY(MAX));
INSERT INTO Foobar
(image_data)
SELECT image_data
FROM OPENROWSET(
BULK N'C:\image.jpg',
SINGLE_BLOB)
AS ImageSource(image_data);
HTH,
Plamen Ratchev
http://www.SQLStudio.com
|||Thanks, but I don't know how to implement this. I'd like to actually
store the files within the datatable rather than referencing them from
a file location. Is that possible? Otherwise, can you explain this
to me in further detail?
Thanks again.
Randy
|||That will store them in the database, it is insert script. You do it onces
they are there for access. If you want to do it from .NET code.. I don't
have .NET example, but here is example on how to do it in VB6, maybe you can
convert it.
Private Sub InsertFile()
On Error GoTo ErrorHandler
Dim Index As Long
Dim strSQL As String
Dim rs As ADODB.Recordset
Dim mstream As ADODB.Stream
strSQL = "SELECT * FROM TableName"
Set rs = New ADODB.Recordset
rs.Open strSQL, cn, adOpenDynamic, adLockOptimistic
Set mstream = New ADODB.Stream
mstream.Type = adTypeBinary
mstream.Open
mstream.LoadFromFile FileNameToLoadWithFullPath
rs.AddNew
rs.Fields('FileData').Value = mstream.Read
rs.Update
rs.Close
End Sub
Mohit K. Gupta
B.Sc. CS, Minor Japanese
MCTS: SQL Server 2005
"Randy" wrote:

> Thanks, but I don't know how to implement this. I'd like to actually
> store the files within the datatable rather than referencing them from
> a file location. Is that possible? Otherwise, can you explain this
> to me in further detail?
> Thanks again.
> Randy
>
|||You just need to run this as a query in SQL Server Management Studio. It
will actually store the image data into the table, the reference to the file
location is needed just to load the images.
Here is a more detailed example that may fit better your case. The code
below creates a table with keys and then updates the image column for each
key (based on your initial post I assume this is what you want to do).
CREATE TABLE Foobar (
keycol INTEGER,
image_data VARBINARY(MAX));
-- Insert the keys.
INSERT INTO Foobar (keycol)
SELECT 1
UNION ALL
SELECT 2
UNION ALL
SELECT 3
UNION ALL
SELECT 4
UNION ALL
SELECT 5;
UPDATE Foobar
SET image_data = (
SELECT image_data
FROM OPENROWSET(
BULK N'C:\image1.jpg',
SINGLE_BLOB)
AS ImageSource(image_data))
WHERE keycol = 1;
UPDATE Foobar
SET image_data = (
SELECT image_data
FROM OPENROWSET(
BULK N'C:\image2.jpg',
SINGLE_BLOB)
AS ImageSource(image_data))
WHERE keycol = 2;
-- Continue to load all images...
SELECT keycol, image_data
FROM Foobar;
DROP TABLE Foobar;
HTH,
Plamen Ratchev
http://www.SQLStudio.com
|||Thanks to both of you. I'm working with Plamen's query and got it to
execute successfully, however I'm still not all the way there. A
couple of questions:
1. I can see that the table was created in the Results pane, but I
don't know where this table is actually stored. Of course, the table
is of no use until I can make it part of my db, and I don't see it
listed among the tables in the db. How can I create this table so
that it is a permanent member of my db?
2. In the Results pane, I see a two column table. Column 1 is called
keycol and col 2 is called image_data, as created by the query. There
are five rows, each of which contains an integer value from 1 to 5 in
keycol, also as created by the query. However, the fields in
image_data are blank, at least as viewed through the Results pane.
I'm not sure if the images have actually loaded correctly. To
clarify, I changed the query language to include tha path names for
each of the 5 images that I am trying to import, so I don't think that
is part of the problem.
Thanks a lot for sticking with me on this. I'm sorry that I am so
clueless, but working direclty in SQL Server is completely new to me.
Randy
|||Ignore that last reply. Apparently, I wasn't looking at refreshed
view of the db. The table is there, as are both columns. There was
no data in the table, so I added the key column values and just ran
the UPDATE part of the query, which seems to have populated the
image_data values. Now, i just have to figure out how to pull this
onto my VB form. When I look at the table data, it just says <Binary
Data> in each of the fields, so I'm not certain that I have everything
in place just yet. If I have trouble, I'll re-post.
Thanks for everybody's help!
Randy
|||"Randy" <spam.eastland@.gmail.com> wrote in message
news:1182979823.310482.88750@.e16g2000pri.googlegro ups.com...
> Thanks to both of you. I'm working with Plamen's query and got it to
> execute successfully, however I'm still not all the way there. A
> couple of questions:
> 1. I can see that the table was created in the Results pane, but I
> don't know where this table is actually stored. Of course, the table
> is of no use until I can make it part of my db, and I don't see it
> listed among the tables in the db. How can I create this table so
> that it is a permanent member of my db?
If you just copied my sample query, then at the end of it there is a DROP
TABLE statement. You can comment it out or remove it and then run again to
keep the table. This is the line you need to comment out or remove:
--DROP TABLE Foobar;

> 2. In the Results pane, I see a two column table. Column 1 is called
> keycol and col 2 is called image_data, as created by the query. There
> are five rows, each of which contains an integer value from 1 to 5 in
> keycol, also as created by the query. However, the fields in
> image_data are blank, at least as viewed through the Results pane.
> I'm not sure if the images have actually loaded correctly. To
> clarify, I changed the query language to include tha path names for
> each of the 5 images that I am trying to import, so I don't think that
> is part of the problem.
>
You cannot see the image in the result pane, but rather the binary
representation. If you just right click the table and select Open Table, you
should see something like <Binary data> in the image_data column. If you run
the query and look in Result, you should see something like 0xFFD8... If you
see NULL, then the images were not uploaded successfully. I would suggest to
check the path for the files and if the file names are correct.
HTH,
Plamen Ratchev
http://www.SQLStudio.com

Newbie - Store jpg file in Image Data Type Field

I assume that this is really simple to do once you know how to do it.
I have a very small table, only 5 rows and two columns. Column 0 is
an integer from 1 to 5, and column 1 is supposed to store an image
corresponding to each of the values in column 0. I have the five
different image files in a jpg format. I tried simply copying and
pasting these files into the table, but that didn't work. Can
somebody tell me how to save these jpg files in the table so that I
can use them in my VB.NET application?
Thanks,
RandySQL 2000?
"Randy" <spam.eastland@.gmail.com> wrote in message
news:1182898391.523504.187750@.i38g2000prf.googlegroups.com...
>I assume that this is really simple to do once you know how to do it.
> I have a very small table, only 5 rows and two columns. Column 0 is
> an integer from 1 to 5, and column 1 is supposed to store an image
> corresponding to each of the values in column 0. I have the five
> different image files in a jpg format. I tried simply copying and
> pasting these files into the table, but that didn't work. Can
> somebody tell me how to save these jpg files in the table so that I
> can use them in my VB.NET application?
> Thanks,
> Randy
>|||Actually, SQL Server Management Studio Express|||In SQL Server 2005 you can use OPENROWSET with the SINGLE_BLOB option, like
this:
CREATE TABLE Foobar (
image_data VARBINARY(MAX));
INSERT INTO Foobar
(image_data)
SELECT image_data
FROM OPENROWSET(
BULK N'C:\image.jpg',
SINGLE_BLOB)
AS ImageSource(image_data);
HTH,
Plamen Ratchev
http://www.SQLStudio.com|||Thanks, but I don't know how to implement this. I'd like to actually
store the files within the datatable rather than referencing them from
a file location. Is that possible? Otherwise, can you explain this
to me in further detail?
Thanks again.
Randy|||That will store them in the database, it is insert script. You do it onces
they are there for access. If you want to do it from .NET code.. I don't
have .NET example, but here is example on how to do it in VB6, maybe you can
convert it.
Private Sub InsertFile()
On Error GoTo ErrorHandler
Dim Index As Long
Dim strSQL As String
Dim rs As ADODB.Recordset
Dim mstream As ADODB.Stream
strSQL = "SELECT * FROM TableName"
Set rs = New ADODB.Recordset
rs.Open strSQL, cn, adOpenDynamic, adLockOptimistic
Set mstream = New ADODB.Stream
mstream.Type = adTypeBinary
mstream.Open
mstream.LoadFromFile FileNameToLoadWithFullPath
rs.AddNew
rs.Fields('FileData').Value = mstream.Read
rs.Update
rs.Close
End Sub
--
Mohit K. Gupta
B.Sc. CS, Minor Japanese
MCTS: SQL Server 2005
"Randy" wrote:
> Thanks, but I don't know how to implement this. I'd like to actually
> store the files within the datatable rather than referencing them from
> a file location. Is that possible? Otherwise, can you explain this
> to me in further detail?
> Thanks again.
> Randy
>|||You just need to run this as a query in SQL Server Management Studio. It
will actually store the image data into the table, the reference to the file
location is needed just to load the images.
Here is a more detailed example that may fit better your case. The code
below creates a table with keys and then updates the image column for each
key (based on your initial post I assume this is what you want to do).
CREATE TABLE Foobar (
keycol INTEGER,
image_data VARBINARY(MAX));
-- Insert the keys.
INSERT INTO Foobar (keycol)
SELECT 1
UNION ALL
SELECT 2
UNION ALL
SELECT 3
UNION ALL
SELECT 4
UNION ALL
SELECT 5;
UPDATE Foobar
SET image_data = (
SELECT image_data
FROM OPENROWSET(
BULK N'C:\image1.jpg',
SINGLE_BLOB)
AS ImageSource(image_data))
WHERE keycol = 1;
UPDATE Foobar
SET image_data = (
SELECT image_data
FROM OPENROWSET(
BULK N'C:\image2.jpg',
SINGLE_BLOB)
AS ImageSource(image_data))
WHERE keycol = 2;
-- Continue to load all images...
SELECT keycol, image_data
FROM Foobar;
DROP TABLE Foobar;
HTH,
Plamen Ratchev
http://www.SQLStudio.com|||Thanks to both of you. I'm working with Plamen's query and got it to
execute successfully, however I'm still not all the way there. A
couple of questions:
1. I can see that the table was created in the Results pane, but I
don't know where this table is actually stored. Of course, the table
is of no use until I can make it part of my db, and I don't see it
listed among the tables in the db. How can I create this table so
that it is a permanent member of my db?
2. In the Results pane, I see a two column table. Column 1 is called
keycol and col 2 is called image_data, as created by the query. There
are five rows, each of which contains an integer value from 1 to 5 in
keycol, also as created by the query. However, the fields in
image_data are blank, at least as viewed through the Results pane.
I'm not sure if the images have actually loaded correctly. To
clarify, I changed the query language to include tha path names for
each of the 5 images that I am trying to import, so I don't think that
is part of the problem.
Thanks a lot for sticking with me on this. I'm sorry that I am so
clueless, but working direclty in SQL Server is completely new to me.
Randy|||Ignore that last reply. Apparently, I wasn't looking at refreshed
view of the db. The table is there, as are both columns. There was
no data in the table, so I added the key column values and just ran
the UPDATE part of the query, which seems to have populated the
image_data values. Now, i just have to figure out how to pull this
onto my VB form. When I look at the table data, it just says <Binary
Data> in each of the fields, so I'm not certain that I have everything
in place just yet. If I have trouble, I'll re-post.
Thanks for everybody's help!
Randy|||"Randy" <spam.eastland@.gmail.com> wrote in message
news:1182979823.310482.88750@.e16g2000pri.googlegroups.com...
> Thanks to both of you. I'm working with Plamen's query and got it to
> execute successfully, however I'm still not all the way there. A
> couple of questions:
> 1. I can see that the table was created in the Results pane, but I
> don't know where this table is actually stored. Of course, the table
> is of no use until I can make it part of my db, and I don't see it
> listed among the tables in the db. How can I create this table so
> that it is a permanent member of my db?
If you just copied my sample query, then at the end of it there is a DROP
TABLE statement. You can comment it out or remove it and then run again to
keep the table. This is the line you need to comment out or remove:
--DROP TABLE Foobar;
> 2. In the Results pane, I see a two column table. Column 1 is called
> keycol and col 2 is called image_data, as created by the query. There
> are five rows, each of which contains an integer value from 1 to 5 in
> keycol, also as created by the query. However, the fields in
> image_data are blank, at least as viewed through the Results pane.
> I'm not sure if the images have actually loaded correctly. To
> clarify, I changed the query language to include tha path names for
> each of the 5 images that I am trying to import, so I don't think that
> is part of the problem.
>
You cannot see the image in the result pane, but rather the binary
representation. If you just right click the table and select Open Table, you
should see something like <Binary data> in the image_data column. If you run
the query and look in Result, you should see something like 0xFFD8... If you
see NULL, then the images were not uploaded successfully. I would suggest to
check the path for the files and if the file names are correct.
HTH,
Plamen Ratchev
http://www.SQLStudio.com|||VB.NET you should be able to grab the binary data from the database, store
it in a Byte() array and create a Graphics object from it. I'm doing
something similar right now in VB 2005 with dynamically generated images
being passed from SQL Server to a client-side VB app where the binary
content is converted to a bitmap and displayed on a form. Just be sure to
properly dispose of your Graphics objects, etc., when you're done with them.
"Randy" <spam.eastland@.gmail.com> wrote in message
news:1182982110.182760.129310@.e16g2000pri.googlegroups.com...
> Ignore that last reply. Apparently, I wasn't looking at refreshed
> view of the db. The table is there, as are both columns. There was
> no data in the table, so I added the key column values and just ran
> the UPDATE part of the query, which seems to have populated the
> image_data values. Now, i just have to figure out how to pull this
> onto my VB form. When I look at the table data, it just says <Binary
> Data> in each of the fields, so I'm not certain that I have everything
> in place just yet. If I have trouble, I'll re-post.
> Thanks for everybody's help!
> Randy
>|||I need to do the exact same thing but in SQL Server 2000.
I have been tinkering with BULK INSERT and OPENROWSET but have not been able
to get anything to load the image data.
Actually in my case, the image data can be a Word document, Excel
spreadsheet, PDF file, text file, etc.
Thank you in advance for any information that you can provide.
Joe|||Hi Joe,
The BULK rowset provider functionality to load BLOBs is only available since
SQL Server 2005.
See the following example by Erland Sommarskog on how this can be done is
SQL Server 2000:
http://www.sommarskog.se/blobload.txt
HTH,
Plamen Ratchev
http://www.SQLStudio.com

Saturday, February 25, 2012

Newbie RDL to RDLC Conversion

Hi,
I am developing a few reports using the Micrsoft report server which
create a "RDL" file. I was wondering if I can directly transfer these
reports to my ASP.Net application and convert them to the RDLC format?
can anybody provide any information about this functionality?
ThanksAssuming they are RS 2005 files all you have to do is change the extension
and bring them into you project.
I looked at using the viewer control in local mode (which is what you are
talking about doing) and if you have a RS server around you are much better
off to use it in server mode. There is a lot of mucking around that you have
to do with local reports. For instance, for a subreport you have to wire up
an event. It is nothing all that difficult but between hooking up events,
retrieving the data etc it is a good bit more effort than just calling the
report and passing a parameter.
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"Momomo" <le_mo_mo@.yahoo.com> wrote in message
news:1188354990.554512.26060@.k79g2000hse.googlegroups.com...
> Hi,
> I am developing a few reports using the Micrsoft report server which
> create a "RDL" file. I was wondering if I can directly transfer these
> reports to my ASP.Net application and convert them to the RDLC format?
> can anybody provide any information about this functionality?
> Thanks
>|||Hi,
Thank you for the response.How do I deal with "RDS (Shared Data
Source)" and "RDL.Data" files? hwo di I migrate those to my web site?
Mo|||I think you are a bit confused about how the control works. First, you are
using the reportviewer control that ships with VS 2005. It comes both as a
webform and as a winform control. Assuming you are then you need to decide
whether you want to use local mode or server mode. In server mode it
connects to RS server. You provide the parameters and it calls and then
displays the report. This is pretty straight forward to implement. In local
mode you give it the report (rdlc file) and hand it the dataset (really a
datatable). You have total control and you have to do more work.
RS does not have an RDL file on the server, it stores the object. You have
to save the report from Report Manager or get it out of the original VS
project that created the reports.
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"Momomo" <le_mo_mo@.yahoo.com> wrote in message
news:1188418919.496400.315330@.57g2000hsv.googlegroups.com...
> Hi,
> Thank you for the response.How do I deal with "RDS (Shared Data
> Source)" and "RDL.Data" files? hwo di I migrate those to my web site?
> Mo
>