|
I always thought ExecuteReader (one or more rows) and ExecuteScalar (single value) return values from the database, where as ExecuteNonQuery only returns the number of rows returned, i.e a write which the Op was asking about
Is the ExecuteReader executing a an insert / update or delete statement something it can do but not by intentional design?
As barmey as a sack of badgers
Dude, if I knew what I was doing in life, I'd be rich, retired, dating a supermodel and laughing at the rest of you from the sidelines.
|
|
|
|
|
Read up more on DataReaders -- they can do anything. The others simply wrap it.
|
|
|
|
|
Cheers will do
As barmey as a sack of badgers
Dude, if I knew what I was doing in life, I'd be rich, retired, dating a supermodel and laughing at the rest of you from the sidelines.
|
|
|
|
|
What Simon said. Also look at INSERT and UPDATE in SQL, both of which use ExecuteNonQuery .
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
DatabaseAccessor[^]
Tichaona J wrote: Convert.ToString(
I suspect that that is completely needless in this case, if the value in the database is already a string then a simple cast is all you need.
Don't use the Convert class!
|
|
|
|
|
hi
i try to backup and restore database using sql-server 2008 and got error.
to backup i done this:
BACKUP DATABASE MyDB TO DISK='d:\MyDB.BAK' (and its work fine)
to restore i done this:
USE MASTER RESTORE DATABASE MyDB FROM DISK='d:\MyDB.BAK
and got this error:
Msg 3159, Level 16, State 1, Line 7
The tail of the log for the database "MyDB " has not been backed up. Use BACKUP LOG WITH NORECOVERY to backup the log if it contains work you do not want to lose. Use the WITH REPLACE or WITH STOPAT clause of the RESTORE statement to just overwrite the contents of the log.
Msg 3013, Level 16, State 1, Line 7
RESTORE DATABASE is terminating abnormally.
Where I'm wrong ? what is missing ?
thank's in advance
|
|
|
|
|
The database MyDB is already exists. Consider using WITH REPLACE to overwrite the database.
Here [^] is more about restore.
|
|
|
|
|
thank's for the help !
can i get a simple sample for what i need to do with my example ?
|
|
|
|
|
Perhaps this would help
RESTORE DATABASE MyDB FROM DISK='d:\MyDB.BAK' WITH REPLACE
|
|
|
|
|
thank's for the help, but i got this error:
Msg 3101, Level 16, State 1, Line 7
Exclusive access could not be obtained because the database is in use.
Msg 3013, Level 16, State 1, Line 7
RESTORE DATABASE is terminating abnormally.
|
|
|
|
|
You can't do a restore on a database that is in use. So you will first have to kill all clients accessing the database, either by stopping them or forcefully disconnecting them from the database. Check the activity using the 'Activity Monitor'.
|
|
|
|
|
Well your error message suggest the problem. Close all applications using the database you want to restore. Close all SSMS windows using the database you want to restore. And when you are running restore query use master database.
Try to read the error messages in all cases. That will help you understand any problem.
|
|
|
|
|
Hi
I need to create an inventory database using sql server 2008 and want to know on how i will proceed, what are the steps,etc ? can someone please provide me with some advice?
Thanks
|
|
|
|
|
0) Download SQL Server 2008 R2 Express[^]
1) Install it
2) Read up on relational database management systems
3) Read up on database normalisation
4) Perform an inventory of what you have and decide how you want to represent it in your database
5) Ask more specific questions in online fora
Really, it depends on what you have and how you picture it in your head.
The more tables the better!
|
|
|
|
|
PIEBALDconsult wrote: The more tables the better
Ehm, only if you really need them...
"When did ignorance become a point of view" - Dilbert
|
|
|
|
|
I once inherited a database in whcih the original programmer had created seperate tables for each and every field - eg instead of:
Table "clients":
ID
Name
Address
PostCode
etc
They had:
Table "clients"
ID
Name
Table "addresses"
ClientID
Address
Table "PostCodes"
ClientID
PostCode
etc et-bloody-cetera.... dozens of tables.
You can just imagine the SQL statements....
|
|
|
|
|
If you have a table with very many columns and you often select just a subset of them, then I can understand if you split the table for performance reasons. But what you inherited is just ridiculous.
And it doesn't have anything to do with normalization.
"When did ignorance become a point of view" - Dilbert
|
|
|
|
|
Look here:
Data Models[^]
for database design options.
I don't speak Idiot - please talk slowly and clearly
'This space for rent'
Driven to the arms of Heineken by the wife
|
|
|
|
|
thanks that help a lot, cheers
|
|
|
|
|
Hi,
I'm developing a multilanguage web site.(My DB is SQL Server 2008 R2)
Some of its languages are: Chinease, Japanesae, Arabic, Persian, English ....
I know about some collation and datatypes in SqlServer, but I'm ambigious about Collation of DB and about char types.
1. What collation I shoud use for my DB?
2. for char types I shoud use varchar or nvarchar?
Thanks for your attention.
Best wishes
|
|
|
|
|
Mixing cultures in a database are a recipe for severe headache's.
mehrdadc48 wrote: What collation I shoud use for my DB?
The appropriate one for the required sort-method (binary or dictionary? case sensitive, or not?) for the language, they're listed here[^].
mehrdadc48 wrote: for char types I shoud use varchar or nvarchar?
NVARCHAR , NTEXT and/or NCHAR .
Important note;
Windows Unicode-only collations can only be used with the COLLATE clause to apply collations
to the nchar, nvarchar, and ntext data types on column-level and expression-level data; they
cannot be used with the COLLATE clause to change the collation of a database or server instance. Says so here[^]. That page also mentions that there's three different levels where you can manage your collations. I'd like to suggest that you append the collation that's required by the current UI to the query.
Are you also going to store dates from regions where they speak those languages? If that's the case, you'd also need to check whether the datatimes in the database are all stored in the same timezone (using server-time!) or the local users' time. The latter should be entered in the database re-adjusted to the timezone of your server, or, alternatively, stored the timezoneinformation in an accompanying field.
That should be enough to get you up and running. Enjoy
I are Troll
|
|
|
|
|
I am in the process of writing multiple reports for a system developed using Visual Studio 2008 (VB.Net)and running SSRS 2008. Is it possible when you click a "Print" button that rather than the report showing up in the report viewer window first, that the report be sent directly to the printer without viewing it in a window first. Unfortunately, since I am fairly new to Reporting Services, I cannot figure out the process to do this.
So basically, is there a way I can print a report without viewing it first?
Other....
I know the users are going to ask as well as sending the report directly to printer, to save it in a PDF format. Can this be done?
|
|
|
|
|
I am looking for the steps on how to save and how to read images from/to mysql using C#?
Thanks.
|
|
|
|
|
jrahma wrote: I am looking for the steps on how to save and how to read images from/to mysql using C#?
Would a CodeProject article[^] on the subject help?
I are Troll
|
|
|
|
|
hello - how can you configure auto shrink for SQL server Trasnaction log?
Thanks
dev
|
|
|
|