473,385 Members | 1,772 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,385 software developers and data experts.

connecting ms access database with vb.net

hello all
i have a big problem with my system, can anyone help me plz

there`s some kind of error, there are 2 text box on my interface, 1 for entering an account number and one for entering password, there is a login button also.

here is the code when clicking on the button but it does not work!!! plz
Expand|Select|Wrap|Line Numbers
  1. helpPrivate Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2.         Dim connection As New OleDb.OleDbConnection
  3.  
  4.         Dim command As New OleDbCommand
  5.         Dim DataReader1 As OleDbDataReader
  6.         Dim selectall As String
  7.         Dim Account_No As String = txtAccount.Text
  8.         Dim Password As String = txtPassword.Text
  9.         connection = New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Datasource=db1.mdb")
  10.  
  11.         selectall = "select * FROM Security WHERE A/c_number= " & Account_No & " and Password = " & Password & ""
  12.         command = New OleDbCommand(selectall, connection)
  13.         connection.Open()
  14.         DataReader1 = command.ExecuteReader()
  15.         If DataReader1.HasRows Then
  16.             MessageBox.Show("ok")
  17.         Else
  18.             MessageBox.Show("incorrect Account_No or password")
  19.         End If
  20.  
  21.     End Sub
  22. End Class
Oct 19 '07 #1
4 1278
kenobewan
4,871 Expert 4TB
Do you get an error? Which line number?
Oct 19 '07 #2
Plater
7,872 Expert 4TB
You would probably also have to give a better path to your mdb file then just "db1.mdb", if it errors there you should probably give a full path?
Oct 19 '07 #3
kenobewan
4,871 Expert 4TB
Maybe selectall = "select * FROM Security WHERE A/c_number= ' " & Account_No & " ' and Password = ' " & Password & " ' " will help also, if there is no error. HTH.
Oct 19 '07 #4
bhar
37
Hi,

Working with the OleDbConnection object is similar to using the SqlConnection object. However, because the OleDb.NET data provider can be used to connect to several types of databases, you must specify a provider name in the connection string. These provider names will be the same ones that were used with earlier versions of ADO. Here is an example of a connection string for a Microsoft Access database:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim myConn As OleDbConnection =New OleDbConnection()
  3.  
  4. myConn.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\data\northwind.mdb; User ID=guest; Password=p5n65"
  5.  
If you are working in Visual studio.NET, a reference will automatically be set to the System.Data.dll for most project types. If not, you must add this reference manually. The System.Data.dll assembly supports both System.Data.SqlClient and System.Data.OleDb. If you install teh ODBC data provider or any other third-party providers, you will have to set references to teh appropriate assemblies.


hope this helps.<Advertising link removed>
Oct 22 '07 #5

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

Similar topics

4
by: John Morgan | last post by:
I have Enterprise Manager on my local machine. For the last twelve months it has been connecting without problem to my online SQL Server database provided by my ISP. Three weeks ago the ISP...
2
by: news | last post by:
We currently have our mySQL server on the same box as the Apache server. For security and load balancing, we're going to be moving the mySQL server to another box. We're already using a single...
1
by: Tim Dol | last post by:
I have inherited a VB6-SP5 program connecting to an Access 2000 database. I'm relatively new to VB/Access programming, so I may overlook something obvious. I'll try to explain the problem I can't...
12
by: Ann Marinas | last post by:
Hi all, I would like to ask for some help regarding separating the asp.net webserver and the sql server. I have created an asp.net application for a certain company. Initially, we installed...
5
by: bill | last post by:
I am having difficulties connecting to a remote Sql server database in VB.net. Lets say my remote server is found at 255.255.255.255 and its name is MyServer. The database is called MyDatabase....
5
by: Sebastian | last post by:
I'm using the following code to connect to an access 2000 database. (with reference to adodb) Public DBvar As New ADODB.Connection() DBvar.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data...
5
by: Al | last post by:
Hi, I am looking for sample VB.net code for working with Access 97 database. I know how to work with SQL but I dont know how to read and writ into access 97. Any help is very much appreciated. ...
2
by: Patrick F | last post by:
Hi, i have SQL Server 2005 and a database set that is called, myCompany the problem is that i cant connect from my page to it, here is from the web.config: ( i have got this connectionstring from...
0
by: =?Utf-8?B?R2lkaQ==?= | last post by:
Hi, I've my win32 application which connecting to my sql database. till now i used MSDE as my database and now i want to upgrade to sql express 2005. after the upgrade i tried to connect to the...
1
by: Yew12 | last post by:
Hi, I'm having problems connecting to a Microsoft Access database. Im using PHP and ODBC but im not using a DNS. The scripts below give no errors but I they only give me a blank white screen. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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
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,...

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.