| | |
Need help with ms access and vb.net
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: May 2007
Posts: 3
Reputation:
Solved Threads: 0
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
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
•
•
Join Date: Jun 2007
Posts: 23
Reputation:
Solved Threads: 0
Dear Blackknight,
Your problem is genuine for any beginner. you can use the following to add new record through add button.
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.
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)
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
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)
Db1DataSet1.Clear() 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. If any problem persists, ask me. Regards Kshiteesh Dim conStr As String = "Provider=Microsoft.JET.OLEDB.4.0;data source=K:\Database\db1.mdb" Dim con As OleDb.OleDbConnection = New OleDb.OleDbConnection(conStr) Dim S As String Dim datagrid1 As New DataGrid S = "select * from add1 where fname='" & TextBox1.Text & "'" Dim da As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter(S, con) da.Fill(Db1DataSet1, "add1") datagrid1.DataSource = Db1DataSet1.DefaultViewManager
•
•
Join Date: Aug 2007
Posts: 6
Reputation:
Solved Threads: 0
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
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
•
•
Join Date: Sep 2007
Posts: 15
Reputation:
Solved Threads: 0
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.
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.
•
•
Join Date: Sep 2007
Posts: 1
Reputation:
Solved Threads: 0
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
Have fun
•
•
Join Date: Aug 2007
Posts: 6
Reputation:
Solved Threads: 0
•
•
•
•
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
Asoke
•
•
Join Date: Aug 2007
Posts: 6
Reputation:
Solved Threads: 0
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
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
![]() |
Similar Threads
- linking database Microsoft Access with VB.NET (VB.NET)
- Understanding inserting data into an Access table using VB.NET (VB.NET)
- how 2 access outlook from vb.net (VB.NET)
- Updating Access Db Using Vb.net 2005 (VB.NET)
- how to connect access with vb.net (VB.NET)
- asp.net application in MAC OS (ASP.NET)
- Cannot surf the Net.. (Web Browsers)
- Microsoft .NET FAQ (ASP.NET)
Other Threads in the VB.NET Forum
- Previous Thread: Crystal Report...can anyone help
- Next Thread: Open HTML
| Thread Tools | Search this Thread |
.net .net2008 2005 2008 access account arithmetic array arrays basic bing button buttons c# center check checkbox code convert crystalreport data database datagrid datagridview date dissertation dissertations dropdownlist excel fade file-dialog filter ftp generatetags google gridview hardcopy images inline input insert intel internet listview mobile monitor ms net networking objects output panel passingparameters picturebox picturebox1 port position print printing problem project read remove save searchbox searchvb.net select serial server shutdown soap sorting survey table tcp temperature text textbox timer timespan toolbox trim update user validation vb vb.net vb.netformclosing()eventpictureboxmessagebox vb2008 vbnet view visual visualbasic visualbasic.net visualstudio visualstudio2008 web winforms wpf year





