473,405 Members | 2,176 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,405 software developers and data experts.

unable to connect to Access DataBase

13
Expand|Select|Wrap|Line Numbers
  1. try
  2.         {
  3.             OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\ikcit.mdb");
  4.             OleDbDataAdapter da = new OleDbDataAdapter();
  5.             da.InsertCommand = new OleDbCommand("Insert into student values(@name,@address,@spno,@smail,@domain,@course)", con);
  6.             da.InsertCommand.Parameters.Add("@name", OleDbType.VarChar).Value = TextBox1.Text;
  7.             da.InsertCommand.Parameters.Add("@address", OleDbType.VarChar).Value = TextBox2.Text;
  8.             da.InsertCommand.Parameters.Add("@spno", OleDbType.Numeric ).Value = TextBox3.Text;
  9.             da.InsertCommand.Parameters.Add("@smail", OleDbType.VarChar).Value = TextBox4.Text;
  10.             da.InsertCommand.Parameters.Add("@domain", OleDbType.VarChar).Value = DropDownList1.Text ;
  11.             da.InsertCommand.Parameters.Add("@course", OleDbType.VarChar).Value = DropDownList2.Text ;
  12.             con.Open();
  13.             da.InsertCommand.ExecuteNonQuery();
  14.             con.Close();
  15.  
  16.         }
  17.         catch (Exception ex)
  18.         {
  19.             Response.Write(ex.Message);
  20.         }
When I am trying to insert some data I am getting error.


Could not find file 'C:\WINDOWS\system32\ikcit.mdb'.

Unable to understand Why??
Thanx in advance
Sep 29 '10 #1
5 1613
Frinavale
9,735 Expert Mod 8TB
Change your Connection String so that Data Source is pointing to the path where the ikcit.mdb file is located.

-Frinny
Sep 29 '10 #2
ezhar
13
Is it not possible to add virtual path rather then physical path?
Sep 30 '10 #3
Frinavale
9,735 Expert Mod 8TB
I don't know...
Sorry.


-Frinny
Sep 30 '10 #4
pod
298 100+
you could setup your path in the project properties under the Settings tab, and call for it by name:
Expand|Select|Wrap|Line Numbers
  1. OLEconn.ConnectionString = My.Settings.MyDatabase
Project->Properties->Settings->ConnectionString :



..but you would still have to provide either a relative or absolute path to your database... I think it is better practice to use an absolute path ...although, if you do not wish, try removing the double backslash from your path
Expand|Select|Wrap|Line Numbers
  1. "Data Source=ikcit.mdb"
Sep 30 '10 #5
ezhar
13
Thanx for the reply
but i got the answer and it is bit simple
http://csharpbyansari.blogspot.com/
Oct 5 '10 #6

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

Similar topics

3
by: Thomas Tsang | last post by:
I am using ASP + IIS + MS access, when running the following codes: set Conn=Server.CREATEOBJECT("ADODB.CONNECTION") conn.open "DRIVER={Microsoft Access Driver (*.mdb)}; " &...
7
by: vigneshwaran G via DotNetMonster.com | last post by:
Hi , I am trying ot connect a VB application to Access database. iam using the following connection string : con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;data source=c:\...
1
by: rajusonavane | last post by:
hi i m helpless on connect oracle or access database with xml programm plz give me sample code of program how to connect thanking you raju
0
by: sandeepl | last post by:
Hi i am trying to connect a Ms access database from Oracle 8i. but getting following error. Pls help me in the same.. ERROR at line 1: ORA-28500: connection from ORACLE to a non-Oracle [ODBC...
0
by: rendanime | last post by:
Hi All I have designed an Access database and now i want to connect it with Delphi 5. Can anyone help?????
0
by: asad56 | last post by:
I am workin with a superstore managment project. I connect Access database with main form . Then it work properly. But now I connect same database with another table or field in another form which is...
2
9815402440
by: 9815402440 | last post by:
hi i want to connect access database which is on remote server (web server). can anybody please tell how to do this? thanx in advance. manpreet singh dhillon hoshiarpur
6
9815402440
by: 9815402440 | last post by:
hi i have a ms access database which is on web server (ftp://www.abc.com) . i want to connect this database using ado in vb6. please help regards manpreet singh dhillon hoshiarpur
1
9815402440
by: 9815402440 | last post by:
Hi. I re-posted this question 5-6 days ago, but nobody answered. In the first thread, a few friends suggested some solutions, but my problem still persists. I have a database which is on...
0
by: vidhyaG | last post by:
Hi, i have a database in my ftp server.and i am developing windows application using C# language.now i want to connect a database from ftp server.i tried but it did not work....so,help me... ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.