944,124 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 7247
  • VB.NET RSS
You are currently viewing page 1 of this multi-page discussion thread
May 5th, 2007
0

Need help with ms access and vb.net

Expand Post »
hi am a newbie to the vb.net thing. am using ms access for my database. i have a customer table in my database where sutomer details like first name, last name, address, etc are stored. i've created a form in vb.net and i have a text box, a datagrid and a search button. i want to do a search by name when i enter a customer name in the text box. the customer information will be displayed in the datagrid just like in a database. i can't write the codes and i have spent days looking for codes on the net. all i get is sql ones and am not familiar with sql. here are some codes i have been able to write to connect the database. not sure if it's good though.
please help me out.

Dim UP AsNew OleDb.OleDbCommand
Dim Con As New OleDb.OleDbConnection
Dim Read As OleDb.OleDbDataReader
Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
Con.Open()
MsgBox("A Connection to the Database is now open")
End Sub
Private Sub frmSearch_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Replace(Application.StartupPath, "bin", "") & "DataStore.mdb;Mode=ReadWrite;Persist Security Info=False"
UP.Connection = Con
UP.CommandType = CommandType.Text
UP.CommandText = "Select Customer * From Customer "
End Sub
Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
Me.Close()
End Sub
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
blackknight2114 is offline Offline
3 posts
since May 2007
Aug 21st, 2007
0

Re: Need help with ms access and vb.net

Dear Blackknight,

Your problem is genuine for any beginner. you can use the following to add new record through add button.

VB.NET Syntax (Toggle Plain Text)
  1.  
  2. Dim con As New ADODB.Connection
  3.  
  4. Dim tmp As New ADODB.Recordset
  5. Dim s As String
  6.  
  7. con.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source=K:\Database\db1.mdb"
  8. con.Open()
  9. s = "select * from add1"
  10. tmp.Open(s, con, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockPessimistic)
  11. tmp.AddNew()
  12. tmp.Fields("ID").Value = T18.Text
  13. tmp.Fields("Salutation").Value = T1.Text
  14. tmp.Fields("Fname").Value = T2.Text
  15. tmp.Fields("Mname").Value = T3.Text
  16. tmp.Fields("Lname").Value = T4.Text
  17. tmp.Fields("Degree").Value = T5.Text
  18. tmp.Fields("Category").Value = T6.Text
  19. tmp.Fields("Position").Value = T17.Text
  20. tmp.Fields("Org").Value = T16.Text
  21.  
  22. tmp.Update()
  23. MsgBox("Record Saved")
  24. Exit Sub

To display data in data grid you have to drag datagridview dataset and databinding source from the tool box and connect it to a data base. you can then write following code in the search button to show the items in the datagrid from the access table.
VB.NET Syntax (Toggle Plain Text)
  1.  
  2. Db1DataSet1.Clear()
  3.  
  4. the aforementioned search option is by first name you can change accordingly your field names creating different forms and creating the links of those forms in a single menu form.
  5.  
  6. If any problem persists, ask me.
  7.  
  8. Regards
  9.  
  10. Kshiteesh
  11. Dim conStr As String = "Provider=Microsoft.JET.OLEDB.4.0;data source=K:\Database\db1.mdb"
  12. Dim con As OleDb.OleDbConnection = New OleDb.OleDbConnection(conStr)
  13. Dim S As String
  14. Dim datagrid1 As New DataGrid
  15. S = "select * from add1 where fname='" & TextBox1.Text & "'"
  16. Dim da As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter(S, con)
  17. da.Fill(Db1DataSet1, "add1")
  18. datagrid1.DataSource = Db1DataSet1.DefaultViewManager
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Kshiteesh is offline Offline
23 posts
since Jun 2007
Aug 23rd, 2007
0

Re: Need help with ms access and vb.net

I am trying to use the following to open an MS access DB.

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim SelectText As String = "Select * from myTable"

Dim SqlConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='C:\DesignDentalStudio\DesignDentalStudio\Werner Style Tracking 2006.mdb"

Dim myDA As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter(SelectText, SqlConn)
End Sub
End Class

Geting an error:

ArgumentException was unhandled.
Format of the initialization string does not conform to specification starting at index 33. The last line with Dim is highlighted by yellow.

What is the error. can anyone pl comment?Y Or, please give a reference to a complete code to open an access DB from a VB.NET form. Thanks in advance.

ASoke
Reputation Points: 10
Solved Threads: 0
Newbie Poster
bka_k@Yahoo.com is offline Offline
6 posts
since Aug 2007
Sep 13th, 2007
0

Re: Need help with ms access and vb.net

Hi I have tried to use this code Dim con As New ADODB.Connection

Dim tmp As New ADODB.Recordset
Dim s As String

con.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source=K:\Database\db1.mdb"
con.Open()
s = "select * from add1"
tmp.Open(s, con, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockPessimistic)
tmp.AddNew()
tmp.Fields("ID").Value = T18.Text
tmp.Fields("Salutation").Value = T1.Text
tmp.Fields("Fname").Value = T2.Text
tmp.Fields("Mname").Value = T3.Text
tmp.Fields("Lname").Value = T4.Text
tmp.Fields("Degree").Value = T5.Text
tmp.Fields("Category").Value = T6.Text
tmp.Fields("Position").Value = T17.Text
tmp.Fields("Org").Value = T16.Text

tmp.Update()
MsgBox("Record Saved")
Exit Sub

but VB.NET doesnot recognise that format.
Am need of a search for my customers database too could any one help us out with that problem.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
TransKim is offline Offline
15 posts
since Sep 2007
Sep 18th, 2007
0

Re: Need help with ms access and vb.net

check this site www.startvbdotnet.com it has all that you all seek, its awesome, n don 4get, u owe me 1, lol.
Have fun
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sudantoy is offline Offline
1 posts
since Sep 2007
Sep 18th, 2007
0

Re: Need help with ms access and vb.net

Click to Expand / Collapse  Quote originally posted by sudantoy ...
check this site www.startvbdotnet.com it has all that you all seek, its aweThis Website does not apparantly provide anything on how to open a DB from VB.NET.

ASokesome, n don 4get, u owe me 1, lol.
Have fun
This Website does not apparantly give anything on how to open a DB from VB.NET form.

Asoke
Reputation Points: 10
Solved Threads: 0
Newbie Poster
bka_k@Yahoo.com is offline Offline
6 posts
since Aug 2007
Sep 19th, 2007
0

Re: Need help with ms access and vb.net

You need to get reference of ado.net. then only that will work or support.

Just go to add reference in the menu bar and double click ado.net. you will get the problem solved..

Regards

Kshiteesh
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Kshiteesh is offline Offline
23 posts
since Jun 2007
Sep 19th, 2007
0

Re: Need help with ms access and vb.net

I did that. It's giving this error. acc.db is not a stringHow do I know that ADO.net is created?

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim LevelOneFloorFourTeamOneGeneralistsKunelis1 As String
LevelOneFloorFourTeamOneGeneralistsKunelis1.accdb()
End Sub
Reputation Points: 10
Solved Threads: 0
Newbie Poster
bka_k@Yahoo.com is offline Offline
6 posts
since Aug 2007
Oct 7th, 2011
-1

VB.Net with MS-Access

I need code for vb.net 2008 . That is i have invoice number automatic generation. i used tab control . when i clicked tab automatically invoice number generated which is already saved in database+1.
For example ..already my database have EC000 means , when i click tab automatically print EC001 . that is increment one.
please reply ......
Reputation Points: 8
Solved Threads: 0
Newbie Poster
siva28 is offline Offline
22 posts
since Oct 2011
Oct 7th, 2011
0
Re: Need help with ms access and vb.net
see here
Reputation Points: 43
Solved Threads: 67
Veteran Poster
Netcode is offline Offline
1,016 posts
since Jun 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: How to add a button to title bar
Next Thread in VB.NET Forum Timeline: Problem in retriving data from ms-access to vb.net





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC