473,789 Members | 2,100 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

v.b 6.0 connection with adodc through sqlserver not working

31 New Member
Hi all,

I,m new to vb.6.0 and i don,t know how to connect to sql server through v.b 6.0 with the help of adodc control, and anyone plz tell me how connect and insert ,update,delete and other functions, coz i tried in m.s access not in sqlserver,

This is the coding which i used in ms.access
Expand|Select|Wrap|Line Numbers
  1. 'for insert
  2. rs.Fields(0) = Text1.Text
  3. rs.Fields(1) = Text2.Text
  4. rs.AddNew
  5. rs.Update
  6.  
  7. for update
  8.  
  9. rs.Fields(0) = Text1.Text
  10. rs.Fields(1) = Text2.Text
  11. rs.Update
  12. MsgBox "You suceesfully inserted the value"
  13. adodc1.Refresh
  14. Grid1.Refresh
  15.  
  16. for select
  17. Dim con As ADODB.Connection
  18. Dim rs As ADODB.Recordset
  19. Dim strconnect As String
  20. Set con = New ADODB.Connection
  21. Set rs = New ADODB.Recordset
  22. strconnect = "Driver={SQL Server};Server=FOCUSSERVER;Database=Northwind;Uid=sa;"
  23. con.Open strconnect
  24. rs.Open "select * from Sales", con, adOpenDynamic, adLockOptimistic
  25. MsgBox "Connected Suceesfully"
  26.  
  27. 'for delete
  28. rs.Delete
  29. MsgBox "You suceesfully deleted the record"
  30. rs.MoveFirst
  31. Adodc1.Refresh
  32.  
can anyone plz tell me what changes should i do in above codings or send me some sample coding plz urgent
Apr 3 '08 #1
6 4109
QVeen72
1,445 Recognized Expert Top Contributor
Hi,

You are trying to Connect through ADODC or using ADO Objects...?

Is your Conn Object Opened properly...?

Regards
Veena
Apr 3 '08 #2
hussainiyad
31 New Member
yeah i,m trying with adodc control but there is no connection in datagrid if i right click the adodc control and specify the following details
1datasource
2databasename
3tablename
then the records fetch in the table but if i,m trying trough coding it was not working and also tell me about the insert,update,d elete codings
plzzzzzzzzzzzzz zzzzzzzzzzzz
Apr 3 '08 #3
QVeen72
1,445 Recognized Expert Top Contributor
Hi,

Add a New ADODC to your Form, and Give this in property "ConnectionStri ng"

Provider=SQLOLE DB.1;Password=M yPassword;Persi st Security Info=True;User ID=MyLoginName; Initial Catalog=MYDBNAM E;Data Source=MyServer Name

First Create a "Public" user in SQL Server.. Give Permissions To this User.
Change Connection String Accordingly..

and In "RecordSour ce" property: Click on "..."
and Give:
CommandType = 1 - cmdText
Command Text = "Select * From Myable

and Give DataGrid's datasource = this adodc1.

Regards
Veena
Apr 3 '08 #4
hussainiyad
31 New Member
Thank you veena , i,v done the all above things what u mentioned but i need a clarity about the insert,update.d elete commands while we r using adodc dontrol
Thanks in advance
Apr 3 '08 #5
QVeen72
1,445 Recognized Expert Top Contributor
Hi,

Expand|Select|Wrap|Line Numbers
  1. 'Add Code
  2. Adodc1.Recordset.AddNew
  3. Adodc1.Recordset.Fields(0) = Text1.Text
  4. Adodc1.Recordset.Fields(1) = Text2.Text
  5. Adodc1.Recordset.Update
  6.  
  7. 'Edit Code
  8. ' Move to the Record and 
  9. Adodc1.Recordset.Fields(0) = Text1.Text
  10. Adodc1.Recordset.Fields(1) = Text2.Text
  11. Adodc1.Recordset.Update
  12.  
  13. 'Delete Code
  14. 'Move to the Record
  15. Adodc1.Recordset.Delete
  16.  
  17. ' To Move /Search To a Particular Field, (Usually PK of the Table)
  18.  
  19. Adodc1.Recordset.MoveFirst
  20. Adodc1.Recordset.Find "MyFieldName='" & Text1.Text & "'"
  21. If Adodc1.Recordset.EOF Then
  22.     MsgBox "Search Not Found"
  23. Else
  24.     'Code To Populate / Edit / Delete
  25. End If
  26.  
  27.  
After Update (for all above Data Operations) it is better to Refresh the Datacontrol.

I hope its Clear

Regards
Veena
Apr 3 '08 #6
hussainiyad
31 New Member
Thank you veena for spending on me some time
Apr 3 '08 #7

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

Similar topics

1
2015
by: Steve | last post by:
I'm trying to get some data out of SQLServer on our Webserver. I built the database on my local machine and the code pages are on my C: drive and the virtual folders are in IIS running on my local machine. The following connection string works fine (TRHXP210 is my maching name):- Private Const m_strConnection As String
1
2053
by: mdurliSPAMFILTER | last post by:
Hello, I developed a win32 .exe CGI that connects to a clustered SQLServer to report some data. The software is written with Borland C++Builder. This is the oledb string: Name=Provider=SQLOLEDB;Password=xxx;Persist Security Info=True;User ID=xxxx;Data Source=xxxxx;Initial Catalog=xxxxx;Network Library=dbmssocn It suddendly stopped working on my customer network, so I made some
29
7074
by: Bryce K. Nielsen | last post by:
Suddenly this week, I've started getting this error message: System.Data.SqlClient.SqlConnection(GetOpenConnection)ExecuteNonQuery requires an open and available Connection. The connection's current state is connecting. I'm very puzzled since I'm not calling "ExecuteNonQuery" and I am calling "Open", which I've always assumed was Synchronous, i.e. would not return until either A) the connection was open or B) there was an error. Here...
1
8536
by: Ariane | last post by:
I have an ADODC object in my form which populates a datagrid. I set the coonection string for ADODC at design time. The problem is that I have no way to close the connection when i exit the application. The lock file which the connection creates persists even after I exit. This is what I write in form_unload:
0
959
by: shreshta | last post by:
hello, this is the code i wrote for my application to retrieve values,delete values,update values and insert values... i am havin doubt in delete and retrieve snippets whether it works right. and deletion should ask for the primarykey which is traderid over here and on getting it,it retrieves all details for the particular user and deletes it. i couldnt check out right now as i dont have connection. 'adodc control Private Sub...
4
2971
by: shreshta | last post by:
this is the code i wrote for my application to retrieve values,delete values,update values and insert values... i am havin doubt in delete and retrieve snippets whether it works right. and deletion should ask for the primarykey which is traderid over here and on getting it,it retrieves all details for the particular user and deletes it. i couldnt check out right now as i dont have connection. 'adodc control Private Sub...
1
2175
by: hussainiyad | last post by:
Dear all, i,m new to v.b and i tried to connect to sqlserver through adodc in a datagrid or datalist , but there was no result in my form, can any one tell me what's the reason and i done every thing to connect with the sql step 1:Right click the adodc control declared the provider,database,pwd step2.: In choose Record source i declaled the commad type as "cmd table" and as well the table name step 3 : Draged a data grid and declared the...
0
1559
by: TG | last post by:
Hi! Once again I have hit a brick wall here. I have a combobox in which the user types the server name and then clicks on button 'CONNECT' to populate the next combobox which contains all the databases in that server. Then after the user selects a database, I have another button that he/she click and I want to retrieve file groups from a specific table. At this point when he/she clicks on that button I get an error:
2
2449
by: TG | last post by:
Hi! Once again I have hit a brick wall here. I have a combobox in which the user types the server name and then clicks on button 'CONNECT' to populate the next combobox which contains all the databases in that server. Then after the user selects a database, I have another button that he/she click and I want to retrieve file groups from a specific table. At this point when he/she clicks on that button I get an error:
0
9657
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10393
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9974
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9007
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7523
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5412
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4084
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3687
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2902
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.