|
You want to execute both statements in the same try/catch , rioughly:
try
{
t=begintransaction
cmd1.t=t
cmd2.t=t
cmd1.execute
cmd2.execute
commit
}
catch
{
rollback
}
finally
{
close
}
|
|
|
|
|
my problem: i can't see tables or views of my database in Visual Studio when i export that database to another computer.
i make a sql database in SQL server management studio 2005, everything works fine, i make a connectionstring in my windows application project, also that works fine.
i export my database.. i import the database on another computer (with exactly same settings) but when i make a connectionstring, i don't see any tables or views in visual studio.. in SQL server management studio i do see the tables and vieuws
can anyone help me with this problem?
|
|
|
|
|
How do i set a column to Current time and date? SQl ofcause
Vuyiswa
|
|
|
|
|
UPDATE MyTable
SET SomeColumn = GETDATE()
|
|
|
|
|
Thank you Man
at first i used it like
update property
set archive_date = GETDATE() and ARCHIVE_USER_ID= '107'
where Num_key = '0063'
then i wasnt sure if there is something wrong with Getdate, so i removed the "And" and put a Comma and its working mam , i wanted to make sure that am using the correct function.
update property
set archive_date = GETDATE() ,ARCHIVE_USER_ID= '107'
where Num_key = '0063'
thanks
Vuyiswa
|
|
|
|
|
UPDATE table SET column = GETDATE() WHERE condition
GETDATE() returns the current local date and time. If you're trying to perform calculations on the difference between two values, it may be better to use GETUTCDATE() (returns current UTC date and time) as that will not have the discontinuities of the local date and time if the local time zone uses daylight saving. It might also be better if you have users in multiple time zones and you want to display the time in the user's zone - it's easier to compute this from the UTC time.
Having said that, Windows (at least before Windows Vista) only stores the current time zone information. If the time zone data (e.g. daylight savings start date, end date) changes, the displayed local time for historical data, before the last change, could be incorrect if converting from UTC. You'll have to weigh these issues up against each other.
If you're trying to use the date and time for uniqueness, be aware that the system clock ticks in rather large intervals - normally around 15ms - and it's quite possible for multiple events to occur in one timer tick period.
|
|
|
|
|
Thank you very much,i understand
Vuyiswa
|
|
|
|
|
Mike Dimmick wrote: You'll have to weigh these issues up
... before deciding whether or not DST is a good idea in the first place. (It isn't.)
|
|
|
|
|
set the value as getdate() into that column
|
|
|
|
|
Hi Thank man,tell me Do you know how can i take input from a vb and insert into a table using stored Procedure. i have created the Stored Procedure, i have connected to the Sqldb, i have created the parameter object i have a problem in Appending
can you help
Vuyiswa
|
|
|
|
|
I have Sql Server 2005 Express installed in my PC and have some database in it. I also have a Laptop where I installed Sql Server 2005 Express too. Is possible to transfer the databases from the my desktop PC to the laptop Sql Server 2005 Express?
|
|
|
|
|
Make a backup on your PC then restore it to the laptop.
|
|
|
|
|
Colin Angus Mackay wrote: Make a backup on your PC then restore it to the laptop.
Is this a better method than detach and attach?
"We are all repositories for genetically-encoded information that we're all spreading back and forth amongst each other, all the time. We're just lousy with information."
- Neal Stephenson
|
|
|
|
|
Jerry Hammond wrote: Is this a better method than detach and attach?
I would say so. Apart from anything else, you only have one file to transfer.
|
|
|
|
|
Thanks. My knee-jerk thought was to detach and attach, but upon reading your explanation further down in this thread I undertsand now why it would not be the optimum choice of action.
"We are all repositories for genetically-encoded information that we're all spreading back and forth amongst each other, all the time. We're just lousy with information."
- Neal Stephenson
|
|
|
|
|
You could also detach the database and then copy the mdf and ldf files over to the new machine. You will have to reattach the files on the main machine and the laptop. The whole point of detach and reattach is to provide a means to share databases and it is allot simpler than backing up and restore method.
_____________________________________________________________________
Our developers never release
code. Rather, it tends to escape, pillaging the countryside all around.
The Enlightenment Project (paraphrased comment)
Visit Me at GISDevCafe
|
|
|
|
|
Aaron VanWieren wrote: The whole point of detach and reattach is to provide a means to share databases
Move, not share.
The whole point of a server based database system is that you don't end up with multiple copies of a database and end up with a complete mess because you no longer know which is the definitive version. This happens a lot with Access.
Aaron VanWieren wrote: it is allot simpler than backing up and restore method
Well, with backup and restore you only have one file to deal with. With detach and attach you have to deal with a minimum of two files and, depending on how your database is set up, it could be a lot more than that. Not only that but the database could span various disks. Heck, it is even possible that SQL Server just takes over an entire disk - so there are no files to detach at all, just a physical disk.
|
|
|
|
|
Good points. Sorry in the over simplification. It really depends on the database specifics.
_____________________________________________________________________
Our developers never release
code. Rather, it tends to escape, pillaging the countryside all around.
The Enlightenment Project (paraphrased comment)
Visit Me at GISDevCafe
|
|
|
|
|
When you post a question like this, you need to provide more information than this. For instance, which database are you using? This does play an important part in answering this question.
If you are using SQL Server 2005, you can use a Common Table Expression (CTE) to solve this problem. There are many examples that you can use for this.
In earlier versions of SQL Server, you will need to do some real hacking at code.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Pete O`Hanlon wrote: When you post a question like this, you need to provide more information than this.
Looks like he didn't want to provide more information.
|
|
|
|
|
Colin Angus Mackay wrote: Looks like he didn't want to provide more information.
Looks like it. Probably homework and the teacher's looked in.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Using ADOX (in C# form application) to update a Jet 4.0 database
Supposedly I should be able to change a column’s REQUIRED property by using this code:
cat.Tables["Products"].Columns["ItemReorderDate"].Properties["Nullable"].Value = true;
Found at:
http://msdn2.microsoft.com/en-us/library/aa140022(office.10).aspx
Unfortunately, it gives this error:
Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.
Is ADOX “Nullable” not compatible with Jet 4.0?
If not, is it possible to change the REQUIRED property to "NO" by a SQL command for Jet 4.0?
Thanks,
Ron
|
|
|
|
|
Hi,
I'm tired of searching a way to save and load an image from a SQL Server 2005 database.
There are lots of examples that explains that, but in the process of saving I don't know why the most part of byte array that contains the image simply disapear...
Can anyone tell me, please, how can we save an image in a SQL Server 2005?
Thank you!
P.S.: I'm using VB.NET 2005.
Miguel Castanheira
|
|
|
|
|
|
Thank you, but I already use that kind of sample with C#.
Unfortunately, I think that the problem is in VB.NET...
I'm need that code to work on VB.NET, because when I use C# it realy works good!
Can you explain me why?
Miguel
|
|
|
|