GIVEN below is vbscript to connect to acess database and insert records into the table using forms
Private Sub Command1_Click()
Set rs = cn.Execute("insert into employee values('txtempname.text',txtempid.text,txtssn.text) ")
rs.Close
cn.Close
End Sub
Private Sub Form_Load()
datafile = "C:\mas.accdb"
With cn
.Provider = "microsoft.ACE.OLEDB.12.0"
.ConnectionString = datafile
.Open
End With
End Sub
GLOBAL SECTION
Global cn As New ADODB.Connection
Global rs As New ADODB.Recordset
Global datafile As String
I am getting error "no value given for one or more parameters ".please help me to fix this error?
3 Replies - 1749 Views - Last Post: 01 October 2012 - 02:57 AM
#1
vb6 to connect to acess database and insert records into the table
Posted 27 September 2012 - 11:59 PM
Replies To: vb6 to connect to acess database and insert records into the table
#2
Re: vb6 to connect to acess database and insert records into the table
Posted 28 September 2012 - 04:35 PM
I think you should check out connectionstring.com for setting up your connection string to MS Access. I would recommend you either go with standard security for OLE DB 4.0 or scroll down to the ODBC section.
Here is an example of how you might go about doing this...
Then you can create an ADODB.Command object and recordsets based off of this connection. Below is a link to an example...
http://www.timesheet...adotutorial.htm
Play around with that and you can get a better idea of how this all works.
Here is an example of how you might go about doing this...
Public Sub Connect() cn.CursorLocation = adUseClient strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mas.accdb;User Id=Username;Password=Userpass;" cn.Open strConn
Then you can create an ADODB.Command object and recordsets based off of this connection. Below is a link to an example...
http://www.timesheet...adotutorial.htm
Play around with that and you can get a better idea of how this all works.
#3
Re: vb6 to connect to acess database and insert records into the table
Posted 29 September 2012 - 10:18 AM
Why dont you just add a data property to your form then add some text boxes and an add button with the code
data1.recordset.addnewthis would automatically add all the data that is in the text boxes but make sure you link each one before doing this.
#4
Re: vb6 to connect to acess database and insert records into the table
Posted 01 October 2012 - 02:57 AM
this is because your insert query is wrong
change the insert query like this
change the insert query like this
"insert into employee values('"+ txtempname.text+ "', "+ txtempid.text +", "+txtssn.text +" ) "
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote






|