Showing posts with label sample. Show all posts
Showing posts with label sample. Show all posts

Monday, March 26, 2012

How to connect to AdventureWorks database

I'm trying to connect to the AdventureWorks sample database, after just installing it from the SQL 2005 setup. I was expecting it to automatically appear in SQL Server Management Studio, but it's not there.

How do I get it to show up there?

-Alex

You will have to attach the databases first. they are just deplyoed to the file location specified in the instalaltion path.

HTH; Jens K. Suessmeyer.

http://www.sqlserver2005.de|||

You may not have installed them. If you go through SQL Server 2005's setup, you need to select the sample databases option.

Paul A. Mestemaker II
Program Manager
Microsoft SQL Server Manageability
http://blogs.msdn.com/sqlrem/

|||

refer this KB http://msdn2.microsoft.com/en-us/library/aa992075(VS.80).aspx

Madhu

|||While installing the SQL 2005 setup, by default the sample databases option will be disabled. You have to explicitly enable this option to install the sample databases.

Wednesday, March 7, 2012

how to commit/rollback

i am using oledb to connect the data server, how to use commit and rollback, I am really newbie, could you be so kind to show me a sample code.
thanks.First :
set implicit_transactions on
then run update / insert
run select to check if OK
If OK, commit
if not, rollback
then you can turn this off again:
set implicit_transactions off

Remember udpates / inserts that are not commited can cause the DB to be blocked / slow for other users.

Hope this helps
HandyMac|||my code (enable commit/rollback) as follow:
But HOW can I commit/rollback in other function.
I mean,do not execute commit/rollback this the exec sql function, in the other function,(let the user chooose,the user can choose rollback even the result is correct).
Thanks for help.
Dim conn As OleDb.OleDbConnection = New OleDb.OleDbConnection(con_str)
Dim trans As OleDb.OleDbTransaction
Dim cmd As OleDb.OleDbCommand = conn.CreateCommand
Dim da As OleDb.OleDbDataAdapter
Dim ds As DataSet
Dim dt As DataTable
'open
Try
conn.Open()
Catch ex As OleDb.OleDbException
MsgBox(ex.Message)
Exit Function
End Try
'
trans = conn.BeginTransaction(IsolationLevel.ReadCommitted )
cmd.Connection = conn
cmd.Transaction = trans
cmd.CommandText = "select * from products"
'exec sql
Dim rolled As Boolean = False
Try
da = New OleDb.OleDbDataAdapter(cmd.CommandText, conn)
cmd.ExecuteNonQuery()
trans.Commit()
MsgBox("commited")
Catch ex As Exception
MsgBox(ex.Message)
trans.Rollback()
MsgBox("rollback")
rolled = True
End Try
If rolled Then
Else
'fill ds
dt = New DataTable("wa")
da.Fill(dt)
grd.DataSource = dt.DefaultView
End If

'closing

conn.Close()
'
Return True