By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,168 Members | 2,598 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,168 IT Pros & Developers. It's quick & easy.

How to connect from to sql server 2008 by using oledb connection?

P: 2
Hi! I have a problem with a connecton from VB.Net to SQL Sever 2008.
My code like this:

Expand|Select|Wrap|Line Numbers
  1. Imports System.Data.OleDb
  2. Public Class Form1
  3. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  4.         Dim connectionString As String
  5.         Dim cnn As OleDbConnection
  6.         connectionString = "Provider=SQLOLEDB;Data Source=KIEVEASNA-PC;Database=dbVitkingHouse;UserID=sa;Password=123"
  7.         cnn = New OleDbConnection(connectionString)
  8.         Try
  9.             cnn.Open()
  10.             MsgBox("Connection Open!")
  11.             cnn.Close()
  12.         Catch ex As Exception
  13.             MsgBox("Can not Open connection!")
  14.         End Try
  15.     End Sub
  16. End Class
When I run this project I recieved and message box " Can not Open connection! "
Any expert help me please!
Apr 27 '12 #1

✓ answered by Trjordan

Did you add a reference to your project?

Share this Question
Share on Google+
3 Replies

P: 1
Did you add a reference to your project?
Apr 28 '12 #2

P: 2
Dear Trjordan!

Could You Answer Me Again Please!
My Question Is That:

What Reference That I Should Add to My Project.

I really thank you for your answer and help me.
Apr 28 '12 #3

P: 21
Instead Of Databse Use
Have you declare the below namespaces
using System.Data;
using System.Data.SqlClient;

Initial Catalog=dbVitkingHouse and try
Apr 29 '12 #4

Post your reply

Sign in to post your reply or Sign up for a free account.