problem ADODB.Connection is not defined

Tyecom

Well-known member
Joined
Aug 8, 2007
Messages
78
Programming Experience
Beginner
I keep getting a error message with this code:

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles backupButton.Click

Dim conn As New ADODB.Connection

'CnStr variable is used to save connection string
Dim CnStr As String

'Sql variable is used to save sql statement
Dim Sql As String

'Initialize connection string
CnStr = "Provider=SQLOLEDB.1;Password=sa;Persist Security Info=True;User ID=sa;Initial Catalog=master;Data Source=(local)"

'The sql statement is used to backup database

Sql = "Backup EFb to Disk = 'F:\EFB\EFBSave.bak'"
WITH DIFFERENTIAL;

conn.Open(CnStr)
conn.Execute(Sql)

conn.Close()
End Sub

Errors:

ADODB.Connection is not defined
Name "Differential" is not declared

Can anyone help me with this? Thanks in advance
 
we dont use adodb any more, use a SqlCommand instead


as for why the other code is wrong.. umm.. same reason that this code is wrong way to put a two line string into vb:


Dim s as String = "This is line one"
This is line two


Er.. how else can I explain this.. I'm not sure I can.. You should be able to see why you cant put multiple line strings into code by wrapping the frist line in "" -- of course vb is going to think that the line underneath is a .NET command and give you a syntax errorn
 
Back
Top