borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Is there any MAX function in VB6 ?)Next Topic (Run VB on LINUX) New Topic New Poll Post Reply
AndreaVB Forum : VB General : db data -->vb in one by one data (using text botton in vb)
Poster Message
axcel-trigger21
Level: Graduate

Registered: 12-03-2007
Posts: 10

icon db data -->vb in one by one data (using text botton in vb)

db data -->vb in one by one data (using text botton in vb)

here the problem,i have a table in ms access and i want to put the record(every record) in textbox in vb.

example

ms access
table
     id no. 123456789
     name. axcel

vb
textbox - "apper will be the data of ms access"
texbox


what can i do? please help me!!!!



thank you very much!


____________________________
axcel-trigger21

15-03-2007 at 08:11 AM
View Profile Send Email to User Show All Posts | Quote Reply
aak_neo
Level: Scholar


Registered: 11-02-2007
Posts: 30
icon Re: db data -->vb in one by one data (using text botton in vb)


ur problem is quite simple. u will have to use ado for this.

two methods are either use adodc control(add from references to ur project) or use ado object model.

for starters use adodc control,right click properties and browse to set the connection string(use:microsoft jet 3.51 or 4.0), apply, set recordset to unknown & select the table in ur dbase. ok

now put in text boxes, set their data source property to adodc1 & then data field property to any field u want.

ur project will be codeless. hope it helps? check out these sites if u tend to use ado:





[Edited by aak_neo on 16-03-2007 at 01:09 AM GMT]

____________________________
You never see past the choices you don't understand

15-03-2007 at 08:08 PM
View Profile Send Email to User Show All Posts | Quote Reply
axcel-trigger21
Level: Graduate

Registered: 12-03-2007
Posts: 10
icon Re: db data -->vb in one by one data (using text botton in vb)

thanks, but the problem is.....

i want to put a botton "ADD,EDIT,DELETE, SAVE,PREVIEW,PRINT" do you have any code for this.using vb express edition 2005...

thank you very much if you can help me of this code! i know this very simple hope you can help me
.

[Edited by axcel-trigger21 on 17-03-2007 at 08:04 AM GMT]

____________________________
axcel-trigger21

17-03-2007 at 08:03 AM
View Profile Send Email to User Show All Posts | Quote Reply
aak_neo
Level: Scholar


Registered: 11-02-2007
Posts: 30
icon Re: db data -->vb in one by one data (using text botton in vb)

there is code in vb for adding new records to db, EDITING AND DELETING BUT I DIDN'T understand save, preview.also tell me what way u r using to connect is it adodc control or connection & recordset object at run time.

assuming u r using conn & recordset object i m giving this foll. examples,

Command  Clauses  Predicates Operators Aggregate Functions  
Create         From        Distinct    AND          Avg  
Drop           Where        Top         OR           Count  
Alter          Group By                   NOT          Sum  
Select            Having                   Between     Max  
Insert           Order By                   Like          Min  
Update                                                           In  
Delete        

With a little inspection you can pretty much guess what each of these pieces of an SQL statement can do. However, here are a couple which you'll not want to miss and which I use pretty regularly. Don't miss the last one in my list, which is a very easy way to sort a recordset!

Select
This is the most basic command which tells VB which fields to show in the recordset.
Delete
Simple, but very powerful means of deleting many records at one time.
From
Defines the Table from which the fields will be extracted.
Where
Precedes the conditions by which records are selected from the database
Order By
Sorts the records by any combination of fields you chose.










To start with you need to create a few variables of the following types



Workspace ADODB.Connection - This is required if you are using Transaction Processes (I will explain later)
Database - This connects to the database Recordset
ADODB.Recordset - This is the table/query level variable
Field ADODB.Field - This allows us to get info about the fields
Connecting to a Database
Dim ad as ADODB.Connection

set ad=New ADODB.Connection
Let ad.ConnectionString= "ODBC;DSN=" & DatabaseName & ";UID=" &
UserName & ";PWD=" & UserPassword
ad.Open
Opening a Table/Query for Viewing
dim ar as ADODB.recordset

set ar=new adodb.recordset
ar.open {SQL Statement}
do while not ar.EOF
  'Put the code here for what to do with the information.
  'The field information can be access by the field name
  intID=ar!IDField
  'Or by the order number it is in the list (starting at 0)
  intString=ar.Field(1).value
  ar.movenext
loop
Change a Record
dim ar as ADODB.recordset

set ar=new adodb.recordset
ar.open {SQL Statement}
ar.execute "INSERT INTO tb(ID,Name) VALUES (10,Anne)"
ADO - Add new record

dim ar as ADODB.recordset

set ar=new adodb.recordset
ar.open {SQL Statement}
ar.addnew
ar!ID=intID
ar!Name=strName
ar.update

ADO - Edit Record

dim ar as ADODB.recordset

set ar=new adodb.recordset
ar.open "SELECT * FROM Tb WHERE tdID=10"
if ar.eof then
  ar.addnew
else
  ar.edit
end if
ar!ID=intID
ar!Name=strName
ar.update

ADO - Delete Record

Dim ar as ADODB.recordset

set ar=new adodb.recordset
ar.open "SELECT * FROM Tb WHERE tdID=10"
if not ar.eof then
  ar.delete
end if

Note: If you open an object when you have finished with it, close it and set it to nothing. For example...

    rs.close
    set rs=nothing

For adodc control, refer
http://pages.cpsc.ucalgary.ca/~saul/vb_examples/tutorial3/index.html

it helped me will help u too. try looking at as many examples on both ways of linking to db conn object method is generally preferred although adodc control is much simpler



____________________________
You never see past the choices you don't understand

20-03-2007 at 02:38 PM
View Profile Send Email to User Show All Posts | Quote Reply
axcel-trigger21
Level: Graduate

Registered: 12-03-2007
Posts: 10
icon Re: db data -->vb in one by one data (using text botton in vb)

thanks, i will try to study this,because as i've said im just new only using visual basic.....thank you very much.....can i i message you in private if i need some help?

thanks,,,and GOD BLESS!!!

____________________________
axcel-trigger21

21-03-2007 at 08:06 AM
View Profile Send Email to User Show All Posts | Quote Reply
axcel-trigger21
Level: Graduate

Registered: 12-03-2007
Posts: 10
icon Re: db data -->vb in one by one data (using text botton in vb)

i study your saple code...but i think...im not using that same...

im sorry im just only new using vb express edition 2005.... the connection is like this...

dataset

sourcebinding....something like that......

____________________________
axcel-trigger21

21-03-2007 at 04:58 PM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : VB General : db data -->vb in one by one data (using text botton in vb)
Previous Topic (Is there any MAX function in VB6 ?)Next Topic (Run VB on LINUX) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder