I've been trying to make a mini backup app using smo on SQL express. I
m doing it in VS.2005. Problem is I can connect the server but not
database. There is no error with the database object but when i try to
get tables count, it always return 0.
My code was like this :
Imports Microsoft.SqlServer.Management.Smo
Imports Microsoft.SqlServer.Management.Common
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
Dim m_connection As New
Data.SqlClient.SqlConnection(My.MySettings.Default.db1ConnectionString.Trim)
Dim m_server As New Server(New ServerConnection(m_connection))
Dim m_database As New Database(m_server, "db1.mdf")
Me.TextBox1.AppendText(vbCrLf & m_server.Name) ' // returns DDG
\SQLEXPRESS
Me.TextBox1.AppendText(m_server.VersionString) ' // returns
9.00.1399.06
Me.TextBox1.AppendText(vbCrLf & m_database.Name) ' // returns
db1.mdf
Me.TextBox1.AppendText(vbCrLf & "No. of tables: " &
m_database.Tables.Count) ' // returns 0. actually there are 2 tables
in the database.
End Sub
Please help me.