| | |
Connectivity of SQL 2000 + VB using ODBC
![]() |
•
•
Join Date: Apr 2008
Posts: 43
Reputation:
Solved Threads: 1
steps i Follow-
1) Go to Control panel-->Admintrative Tools-->Double -click
Data sources(ODBC)-->click Add button-->I choose SQL server(last option), Is it right or wrong option for connecting to SQL 2000.Then a new screen appears Create a New dataSource-->in name textbox,we can write anyname--Right or wrong. suppose i enter sonia, & my server name is .,so I enter . in server & click next button-->On the Next screen i have checked the option With Sql server authentication-->Login Id-sa, Password-->Blank-->Click next button-->Next-->Finish-->Then I click on button Test Data source-->Mesage Comes TESTS COMPLETED SUCCESSFULLY-->OK-->OK-->Ok.
These steps we have to do or not for Connectivity using ODBC.
If yes,then what after these steps we have to do??Plz reply me early ??Thx in advance.
Plz tell me the coding also for insertion of textbox values into the textbox.
1) Go to Control panel-->Admintrative Tools-->Double -click
Data sources(ODBC)-->click Add button-->I choose SQL server(last option), Is it right or wrong option for connecting to SQL 2000.Then a new screen appears Create a New dataSource-->in name textbox,we can write anyname--Right or wrong. suppose i enter sonia, & my server name is .,so I enter . in server & click next button-->On the Next screen i have checked the option With Sql server authentication-->Login Id-sa, Password-->Blank-->Click next button-->Next-->Finish-->Then I click on button Test Data source-->Mesage Comes TESTS COMPLETED SUCCESSFULLY-->OK-->OK-->Ok.
These steps we have to do or not for Connectivity using ODBC.
If yes,then what after these steps we have to do??Plz reply me early ??Thx in advance.
Plz tell me the coding also for insertion of textbox values into the textbox.
the steps you followed for creating the DSN are absolutely correct. but there is no need to create that. it is always recommended that you use a DSN-Less connection. It becomes more faster.
ok...here is a sample connection snippet for you. please note that this code uses DSN-Less connection.
just goto Project->References and add Microsoft Activex Data Objects <Version No.> Library into your project.
look for the Bolded Parts in the connection string. the first one should be replaced by yours database user name and the second one is by your original database name.
for inserting values from textbox to your sql server database use the following code :-
look into the Bolded Part. it must be replaced by your table name where you wish save your records.
hope this helps you.
try this and give me a feedback.
regards
Shouvik
ok...here is a sample connection snippet for you. please note that this code uses DSN-Less connection.
just goto Project->References and add Microsoft Activex Data Objects <Version No.> Library into your project.
''code for making a connection with the sql server database Private Sub Form_Load() Dim gcn as New ADODB.Connection gcn.connectionstring="Provider=SQLOLEDB.1;Persist Security Info=False;User ID=bs;Initial Catalog=BILLING_SYSTEM" gcn.open msgbox "A connection to the database is now established" End Sub ''code for retrieving some rows from a table Private sub Command1_Click() Dim rs as New ADODB.Recordset Dim str as String Dim li as ListItem str="select * from branch_details order by branch_id" rs.open str,gcn,1,2 if rs.Recordcount>0 then rs.MoveFirst While not rs.EOF() with Listview1 set li=.listitems.add(,,(branch_id)) li.subitems(1)=rs!branch_name li.subitems(2)=rs!address end with rs.MoveNext Wend else msgbox "No record found." & vbcrlf & "Please add some records." end if if rs.State=adStateOpen then rs.close set rs=Nothing End Sub
look for the Bolded Parts in the connection string. the first one should be replaced by yours database user name and the second one is by your original database name.
for inserting values from textbox to your sql server database use the following code :-
Dim rs as New ADODB.Recordset
if rs.state=adStateopen then rs.close
rs.open "select * from branch_details",gcn,1,2
rs.AddNew
rs!branch_id=txtID.text
rs!branch_name=trim(txtName.text)
rs!address=trim(txtAddress.text)
rs.Update
if rs.state=adStateopen then rs.close
set rs=nothing
Msgbox "New record added."look into the Bolded Part. it must be replaced by your table name where you wish save your records.
hope this helps you.
try this and give me a feedback.
regards
Shouvik
Last edited by choudhuryshouvi; Apr 7th, 2008 at 3:45 pm.
Shouvik_The_Expert_Coder
Have a problem? Don't worry just give me a call and I'll fix it for you.
Have a problem? Don't worry just give me a call and I'll fix it for you.
not compulsorily.
but you can use the ADODC control.
but it is not recommended. always use ADODB objects to communicate with your databases.
in the preceding code i gave you, you don't require to have any ADODC control on your form.
ok...
tell me if any more problem arises...
regards
Shouvik
but you can use the ADODC control.
but it is not recommended. always use ADODB objects to communicate with your databases.
in the preceding code i gave you, you don't require to have any ADODC control on your form.
ok...
tell me if any more problem arises...
regards
Shouvik
Shouvik_The_Expert_Coder
Have a problem? Don't worry just give me a call and I'll fix it for you.
Have a problem? Don't worry just give me a call and I'll fix it for you.
you don't require that control you mentioned.
infact, you don't require any data controls from your components list to work with this code. for listview control add this ,
Microsoft Windows Common Control 6.0
regards
Shouvik
infact, you don't require any data controls from your components list to work with this code. for listview control add this ,
Microsoft Windows Common Control 6.0
regards
Shouvik
Shouvik_The_Expert_Coder
Have a problem? Don't worry just give me a call and I'll fix it for you.
Have a problem? Don't worry just give me a call and I'll fix it for you.
•
•
•
•
There is so such control in the Components... Microsoft Active X Plug in ..Is it same as which u r saying?/I m working on 6.0.
you are in wrong place.
look at your menu bar inside your vb6 IDE. you will find a menu called Project.
inside it there is a command References... goto there,scroll down and add the reference
Microsoft Activex DataObjects ... Library
choose the highest version.
ok....
Shouvik_The_Expert_Coder
Have a problem? Don't worry just give me a call and I'll fix it for you.
Have a problem? Don't worry just give me a call and I'll fix it for you.
listen carefully my frnd,
Microsoft Activex Data Objects is a reference not a component or control. so it won't be added into the toolbox. each control you use on your vb6 form adds a reference to your project. now if you add an ADODC control on your form it will add the same ref. on your project too. to see this, just add an ADODC control from your component list and now go to Project->References. there you will see Microsoft Activex Data Objects has been added to your project reference list.
i'm telling you again plz read previous replies ten times before you post a reply.
in my previous replies several times i have said that this code doesn't require any control/component to be added on your form. it is using a reference and for that adding MS ADO is enough.
look into the code very carefully. there is a statement Dim gcn as New ADODB.Connection. this is a global variable which is nothing but an instance of ADODB Connection object. so to use this vars or accessing ADO methods/functions inclusion of this reference is very much important. otherwise you will face compilation errors.
hope you'll understand and approach to right direction this time.
regards
Shouvik
Microsoft Activex Data Objects is a reference not a component or control. so it won't be added into the toolbox. each control you use on your vb6 form adds a reference to your project. now if you add an ADODC control on your form it will add the same ref. on your project too. to see this, just add an ADODC control from your component list and now go to Project->References. there you will see Microsoft Activex Data Objects has been added to your project reference list.
i'm telling you again plz read previous replies ten times before you post a reply.
in my previous replies several times i have said that this code doesn't require any control/component to be added on your form. it is using a reference and for that adding MS ADO is enough.
look into the code very carefully. there is a statement Dim gcn as New ADODB.Connection. this is a global variable which is nothing but an instance of ADODB Connection object. so to use this vars or accessing ADO methods/functions inclusion of this reference is very much important. otherwise you will face compilation errors.
hope you'll understand and approach to right direction this time.
regards
Shouvik
Last edited by choudhuryshouvi; Apr 8th, 2008 at 4:38 am.
Shouvik_The_Expert_Coder
Have a problem? Don't worry just give me a call and I'll fix it for you.
Have a problem? Don't worry just give me a call and I'll fix it for you.
•
•
Join Date: Mar 2008
Posts: 324
Reputation:
Solved Threads: 7
Hey choudhary,
Names I have mentioned below are all used to connect to VB or not??
ADO,RDO,ODBC,DAO,OLE DB????
AnyMore methods are there to connect to VB??
Plz just give the names as above.
To connect to ODBC--we require DSN Connection. Right or Wrong?
To connect to OLEDB--we reruire OPEN Connection. Right or Wrong?
Can u plz give me just one-line short descriptions abt the others.
Second thing,The coding given by you to yogesh as scrap,In that method we are connecting using which method???
is that ADO or RDO or DAO.
Names I have mentioned below are all used to connect to VB or not??
ADO,RDO,ODBC,DAO,OLE DB????
AnyMore methods are there to connect to VB??
Plz just give the names as above.
To connect to ODBC--we require DSN Connection. Right or Wrong?
To connect to OLEDB--we reruire OPEN Connection. Right or Wrong?
Can u plz give me just one-line short descriptions abt the others.
Second thing,The coding given by you to yogesh as scrap,In that method we are connecting using which method???
is that ADO or RDO or DAO.
![]() |
Similar Threads
- Database Connectivity in C (C)
- Cannot find server or DNS Error - please help! (Viruses, Spyware and other Nasties)
- Connectivity (C++)
- connectivity in Borland C (C++)
- Ms Sql Server 2000 (MS SQL)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Help with Login scree developed in visual basic 6.0
- Next Thread: Creating Alert in Vb.6
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age application basic beginner birth bmp calculator cd cells.find click client code college component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report save search sendbyte sites sort sql sql2008 sqlserver subroutine tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





