473,386 Members | 1,652 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Cannot connect to a database

HS1
Hello

Me again

I want to create a connection using SqlDataConnection with a a Access
database as following:
Dim da1 As New System.Data.SqlClient.SqlDataAdapter()

Dim da2 As New System.Data.SqlClient.SqlDataAdapter()

Dim conn As System.Data.SqlClient.SqlConnection

conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Password=""; User
ID="";Data Source=C:\myDatabase.mdb"

da1 = New System.Data.SqlClient.SqlDataAdapter("Select * From Clients",
conn)

da2 = New System.Data.SqlClient.SqlDataAdapter("Select * From Jobs", conn)

However it did not work. There is an error at "conn.ConnectionString"
claimed that "Object reference not set to an instance of an object."

Note: I typed correct database name and location. myDatabase has no password
or Id

Could you please help

Many thanks
S.Hoa
Nov 21 '05 #1
6 1296
AFAIK, the Sql* classes are /only/ for Sql Server. So, your SqlConnection
can be used to connect to a Sql Server only. To connect to an access
database, you'll need to use either an OleDbConnection or an OdbcConnection.

hope that helps..
Imran.

"HS1" <so*@slingshot.co.nz> wrote in message
news:1096855654.312670@ftpsrv1...
Hello

Me again

I want to create a connection using SqlDataConnection with a a Access
database as following:
Dim da1 As New System.Data.SqlClient.SqlDataAdapter()

Dim da2 As New System.Data.SqlClient.SqlDataAdapter()

Dim conn As System.Data.SqlClient.SqlConnection

conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Password=""; User
ID="";Data Source=C:\myDatabase.mdb"

da1 = New System.Data.SqlClient.SqlDataAdapter("Select * From Clients",
conn)

da2 = New System.Data.SqlClient.SqlDataAdapter("Select * From Jobs", conn)

However it did not work. There is an error at "conn.ConnectionString"
claimed that "Object reference not set to an instance of an object."

Note: I typed correct database name and location. myDatabase has no
password
or Id

Could you please help

Many thanks
S.Hoa

Nov 21 '05 #2
You have two major problems here. As imran pointed out, you can't use
SqlClient w/ access and you'll need to instaniate your connection before you
try referencing it. Any time you get that exception, make sure you
instantiated the object (with new) .

--
W.G. Ryan MVP (Windows Embedded)

TiBA Solutions
www.tibasolutions.com | www.devbuzz.com | www.knowdotnet.com
"HS1" <so*@slingshot.co.nz> wrote in message
news:1096855654.312670@ftpsrv1...
Hello

Me again

I want to create a connection using SqlDataConnection with a a Access
database as following:
Dim da1 As New System.Data.SqlClient.SqlDataAdapter()

Dim da2 As New System.Data.SqlClient.SqlDataAdapter()

Dim conn As System.Data.SqlClient.SqlConnection

conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Password=""; User
ID="";Data Source=C:\myDatabase.mdb"

da1 = New System.Data.SqlClient.SqlDataAdapter("Select * From Clients",
conn)

da2 = New System.Data.SqlClient.SqlDataAdapter("Select * From Jobs", conn)

However it did not work. There is an error at "conn.ConnectionString"
claimed that "Object reference not set to an instance of an object."

Note: I typed correct database name and location. myDatabase has no password or Id

Could you please help

Many thanks
S.Hoa

Nov 21 '05 #3
Off topic but what does AFAIK mean?

Christopher
"Imran Koradia" <no****@microsoft.com> wrote in message
news:Of**************@TK2MSFTNGP15.phx.gbl...
AFAIK, the Sql* classes are /only/ for Sql Server. So, your SqlConnection
can be used to connect to a Sql Server only. To connect to an access
database, you'll need to use either an OleDbConnection or an
OdbcConnection.

hope that helps..
Imran.

"HS1" <so*@slingshot.co.nz> wrote in message
news:1096855654.312670@ftpsrv1...
Hello

Me again

I want to create a connection using SqlDataConnection with a a Access
database as following:
Dim da1 As New System.Data.SqlClient.SqlDataAdapter()

Dim da2 As New System.Data.SqlClient.SqlDataAdapter()

Dim conn As System.Data.SqlClient.SqlConnection

conn.ConnectionString =
"Provider=Microsoft.Jet.OLEDB.4.0;Password=""; User
ID="";Data Source=C:\myDatabase.mdb"

da1 = New System.Data.SqlClient.SqlDataAdapter("Select * From Clients",
conn)

da2 = New System.Data.SqlClient.SqlDataAdapter("Select * From Jobs",
conn)

However it did not work. There is an error at "conn.ConnectionString"
claimed that "Object reference not set to an instance of an object."

Note: I typed correct database name and location. myDatabase has no
password
or Id

Could you please help

Many thanks
S.Hoa


Nov 21 '05 #4
AFAIK - As Far As I Know
I've been there :)

Imran.

"Christopher Kurtis Koeber" <c_******@myrealbox.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Off topic but what does AFAIK mean?

Christopher
"Imran Koradia" <no****@microsoft.com> wrote in message
news:Of**************@TK2MSFTNGP15.phx.gbl...
AFAIK, the Sql* classes are /only/ for Sql Server. So, your SqlConnection
can be used to connect to a Sql Server only. To connect to an access
database, you'll need to use either an OleDbConnection or an
OdbcConnection.

hope that helps..
Imran.

"HS1" <so*@slingshot.co.nz> wrote in message
news:1096855654.312670@ftpsrv1...
Hello

Me again

I want to create a connection using SqlDataConnection with a a Access
database as following:
Dim da1 As New System.Data.SqlClient.SqlDataAdapter()

Dim da2 As New System.Data.SqlClient.SqlDataAdapter()

Dim conn As System.Data.SqlClient.SqlConnection

conn.ConnectionString =
"Provider=Microsoft.Jet.OLEDB.4.0;Password=""; User
ID="";Data Source=C:\myDatabase.mdb"

da1 = New System.Data.SqlClient.SqlDataAdapter("Select * From Clients",
conn)

da2 = New System.Data.SqlClient.SqlDataAdapter("Select * From Jobs",
conn)

However it did not work. There is an error at "conn.ConnectionString"
claimed that "Object reference not set to an instance of an object."

Note: I typed correct database name and location. myDatabase has no
password
or Id

Could you please help

Many thanks
S.Hoa



Nov 21 '05 #5
Imran,
AFAIK - As Far As I Know
I've been there :)


I am almost sure that is in this question "IK" is enough for you.

:-)

Cor
Nov 21 '05 #6
lol ! good one Cor..

"Cor Ligthert" <no************@planet.nl> wrote in message
news:ez**************@TK2MSFTNGP14.phx.gbl...
Imran,
AFAIK - As Far As I Know
I've been there :)


I am almost sure that is in this question "IK" is enough for you.

:-)

Cor

Nov 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Krista | last post by:
Hi guys, i have a problem about inserting data into the table. I dont know why the output always said cannot be added to the database! Anyone has idea for me? i check the connect is ok, but dont...
4
by: bettina | last post by:
Hello, My domain: www.coaster.ch My database: coasters User: bettina In the programm I wrote: <?php $db_server = "www.coaster.ch";
6
by: Jeff Sandler | last post by:
I have a database I created in mySQL. I've been entering data every day into the database using a Java application that I wrote. The database and the Java program are on the same Win 98 SE...
1
by: ikrabbe | last post by:
Hi, I want to set up a mysql server in an embedded process. I managed to start the server in my program as described through mysql_server_init() Now I need a client connection to this...
2
by: Jay Chan | last post by:
We have just installed a SQL Server 2000 (SP 3A) onto a computer that has Windows-2003 Server on it. Now, we cannot get access to that database server from other computers. Seem like this may be an...
1
by: beck4353 | last post by:
Hi, I am using VS.NET Arch. and I am having problems connecting to ANY database. I am trying to a either a SqlConnection or OleDBConnection object to my project. When I try to define the...
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
10
by: Jean-David Beyer | last post by:
I have some programs running on Red Hat Linux 7.3 working with IBM DB2 V6.1 (with all the FixPacks) on my old machine. I have just installed IBM DB2 V8.1 on this (new) machine running Red Hat...
6
by: antonyliu2002 | last post by:
I was able to view table content easily before, but after I reinstalled everything, I cannot find the option to view table content in MS SQL Server Express. I can define table with no problem. ...
3
by: Raymond Chiu | last post by:
Dear All, I have posted my question as below. But no answers, hope it can found here. ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.