| | |
how to save data from textbox to msaccess 2003
Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved |
Here's a sample
Replace correct strings to connection string, table name and field name, and add some error handling code.
If you have trouble with connection string see Connection strings for Access.
VB.NET Syntax (Toggle Plain Text)
Dim oCon As OdbcConnection Dim oCmd As OdbcCommand Dim ConnStr As String Dim strSQL As String ConnStr = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=<path to mdb file>" oCon = New OdbcConnection(ConnStr) oCon.Open() oCmd = oCon.CreateCommand() strSQL = "INSERT INTO <tablename> (<fieldname>) VALUES ('" & TextBox1.Text.Replace("'", "''") & "')" oCmd.CommandText = strSQL oCmd.ExecuteNonQuery() oCon.Close()
If you have trouble with connection string see Connection strings for Access.
Teme64 @ Windows Developer Blog
•
•
Join Date: Jan 2009
Posts: 7
Reputation:
Solved Threads: 0
hi, thx vey much for the help... as i tld you im very new to vb.net 05...
i have pasted the code in my click method...
well i knw that i have to edit it frst
i have attached a preview of how my code is...
but why is "OdbcConnection" highlighted saying it is not declared. pls check the coding and guide me pls....
i have pasted the code in my click method...
well i knw that i have to edit it frst

i have attached a preview of how my code is...
but why is "OdbcConnection" highlighted saying it is not declared. pls check the coding and guide me pls....
write this on the top of codes
VB.NET Syntax (Toggle Plain Text)
Imports System.Data.Odbc
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
So, Please do something before post your thread.
* PM Asking will be ignored *
•
•
Join Date: Jan 2009
Posts: 7
Reputation:
Solved Threads: 0
hi,
im still having trouble to save data to access..
i have attached my code in JPG format...
My little app is supposed to save data from a textbox to a field in access...
i dont get any errors while running the application.. but it just wont save the data.. cantr understand why...
Pls help... i really need to understand this..
Thank You...
im still having trouble to save data to access..
i have attached my code in JPG format...
My little app is supposed to save data from a textbox to a field in access...
i dont get any errors while running the application.. but it just wont save the data.. cantr understand why...
Pls help... i really need to understand this..
Thank You...
•
•
Join Date: Jan 2009
Posts: 7
Reputation:
Solved Threads: 0
Hi, i managed to make it work.. now my another prob is, how do i amend the code is i had 2 textbox and to save the data into ms access...
i tried this but its not working:
mycommand.CommandText = "INSERT INTO TBLSuppliers (Company, Contact Person) VALUES ('" & txtCompany.Text.Replace , & txtContactPerson.text.replace ("'", "''") & "')"
i tried this but its not working:
mycommand.CommandText = "INSERT INTO TBLSuppliers (Company, Contact Person) VALUES ('" & txtCompany.Text.Replace , & txtContactPerson.text.replace ("'", "''") & "')"
![]() |
Other Threads in the VB.NET Forum
- Previous Thread: DataGrid reads, but not updates!
- Next Thread: vb.net and compact framework?
| Thread Tools | Search this Thread |
.net .net2008 2008 access add advanced application array assignment basic beginner box browser button buttons center click client code combo convert cpu cuesent data database datagrid datagridview datetimepicker designer dissertation dissertations dissertationtopic eclipse editvb.net employees excel exists filter forms function html images isnumericfuntioncall listview map mobile module msaccess mssqlbackend mysql net number open page pan panel pdf picturebox picturebox2 port position print printing printpreview read record regex reuse right-to-left save search serial settings socket sorting sqldatbase sqlserver storedprocedure temp textbox timer timespan transparency txttoxmlconverter usercontol vb vb.net vba vbnet vista visual visualbasic visualbasic.net visualstudio.net web winsock wpf wrapingcode xml year






