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

adding, saving, editing database without adding adodc or datacontrol

55
hi! how do i add a record in a database without using the datacontrol and adodc. i want to rework my code to using purely codes and not being dependent on the design on vb. so far i have.

Expand|Select|Wrap|Line Numbers
  1.  Set rs = New ADODB.Recordset
  2.       Set con = New ADODB.Connection
  3.       con.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source=C:\Program Files\Logsheet\Logsheet.mdb;"
  4.       con.Open
  5.       rs.Open "SELECT * from Employee;", con, adOpenDynamic, adLockOptimistic
  6.        rs.MoveFirst
  7.        Text1.Text = rs.Fields(0)
  8.        Text2.Text = rs.Fields(1)
  9.        Text3.Text = rs.Fields(2)
  10.        Text4.Text = rs.Fields(3)
  11.        Text5.Text = rs.Fields(4)
  12. con.close
  13. rs.close
and when should i close the connections? i also have cmdbuttons add, edit, save, delete any guide on what to write there?

i have trouble adding a record so i'll just also post it here.
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdAdd_Click()
  2. Set rs = New ADODB.Recordset
  3.       Set con = New ADODB.Connection
  4.       con.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source=C:\Program Files\Logsheet\Logsheet.mdb;"
  5.       con.Open
  6.       rs.Open "SELECT * from Employee;", con, adOpenDynamic, adLockOptimistic
  7.  
  8.        rs.MoveLast
  9.        rs.AddNew
  10.  
  11.  
  12.  
  13. End Sub
  14.  
  15. Private Sub cmdSave_Click()
  16. rs.Update
  17. rs.Close
  18. con.Close
  19. End Sub
Dec 10 '07 #1
4 7808
debasisdas
8,127 Expert 4TB
if you want to add a record no need to open the record set.

try this

connction.execute "insert into ................"
Dec 10 '07 #2
jaz215
55
if you want to add a record no need to open the record set.

try this

connction.execute "insert into ................"
ow i see..
so i just use sql statements for all the functions i want..
tnx :P
Dec 10 '07 #3
debasisdas
8,127 Expert 4TB
For any DML execute the sql statment between the block of begintrans and committrans.

Expand|Select|Wrap|Line Numbers
  1. conn.begintrans
  2. conn.execute "........your DML statment..........."
  3. conn.committrans
Dec 10 '07 #4
Killer42
8,435 Expert 8TB
Is it just me, or is there a bit of a trend emerging in ilasabba's responses?

Twelve replies so far, and they all say more or less the same thing (apart from typos).
Dec 17 '07 #5

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

Similar topics

6
by: 6thirty | last post by:
Hi, I've created a stocktaking database using Access XP. This is indexed by two fields - part number and shelf location. I am currently inputting all the data via a form. When I have entered a...
13
by: Stuart McGraw | last post by:
I haven't been able to figure this out and would appreciate some help... I have two tables, both with autonumber primary keys, and linked in a conventional master-child relationship. I've...
5
by: Neo Geshel | last post by:
Greetings. I am in a very big pickle. I am trying to add page content - as well as a submit button - programatically to a web form that is supposed to submit to DB and then refresh. That...
4
by: Newbie | last post by:
Can someone help: Is there a way with ado.net and it's disconnected dataset to delete a record in a table if you can't specify a unique field in an SQL WHERE clause. The current Dbase .dbf...
1
by: poomeh | last post by:
Hi All Can anyone help me, I am struggling to get the code for saving into a microsoft access database using vb6. I have connected using the ADODC because I can't get the connection string...
5
by: dreamonzzz | last post by:
i need help . im using ADODC for my database settings, VB6. can anyone tell me how to edit the database ? need help asap.. thnx allot
0
by: jackvel | last post by:
Hi Dudes... I want to connect the Access database with VB 6.0 without using DataControl and ADODC.. Which option should i use.? Plz send me the detailed procedure of doing the same.. Plz...
2
by: Steve | last post by:
I have zero experience with ODBC. If I have an Access frontend connected to a SQL Database using ODBC, are the tables connected like a frontend/backend Access database where the the tables you see...
18
by: tech | last post by:
Hi, i have a std::vector of pointers to base classes say std::vector<element*m_elements; how do i make the followin exception safe function() { element* e= new DerivedElement;...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.