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 -
'for insert
-
rs.Fields(0) = Text1.Text
-
rs.Fields(1) = Text2.Text
-
rs.AddNew
-
rs.Update
-
-
for update
-
-
rs.Fields(0) = Text1.Text
-
rs.Fields(1) = Text2.Text
-
rs.Update
-
MsgBox "You suceesfully inserted the value"
-
adodc1.Refresh
-
Grid1.Refresh
-
-
for select
-
Dim con As ADODB.Connection
-
Dim rs As ADODB.Recordset
-
Dim strconnect As String
-
Set con = New ADODB.Connection
-
Set rs = New ADODB.Recordset
-
strconnect = "Driver={SQL Server};Server=FOCUSSERVER;Database=Northwind;Uid=sa;"
-
con.Open strconnect
-
rs.Open "select * from Sales", con, adOpenDynamic, adLockOptimistic
-
MsgBox "Connected Suceesfully"
-
-
'for delete
-
rs.Delete
-
MsgBox "You suceesfully deleted the record"
-
rs.MoveFirst
-
Adodc1.Refresh
-
can anyone plz tell me what changes should i do in above codings or send me some sample coding plz urgent
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
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
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
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
QVeen72 1,445
Recognized Expert Top Contributor
Hi, -
'Add Code
-
Adodc1.Recordset.AddNew
-
Adodc1.Recordset.Fields(0) = Text1.Text
-
Adodc1.Recordset.Fields(1) = Text2.Text
-
Adodc1.Recordset.Update
-
-
'Edit Code
-
' Move to the Record and
-
Adodc1.Recordset.Fields(0) = Text1.Text
-
Adodc1.Recordset.Fields(1) = Text2.Text
-
Adodc1.Recordset.Update
-
-
'Delete Code
-
'Move to the Record
-
Adodc1.Recordset.Delete
-
-
' To Move /Search To a Particular Field, (Usually PK of the Table)
-
-
Adodc1.Recordset.MoveFirst
-
Adodc1.Recordset.Find "MyFieldName='" & Text1.Text & "'"
-
If Adodc1.Recordset.EOF Then
-
MsgBox "Search Not Found"
-
Else
-
'Code To Populate / Edit / Delete
-
End If
-
-
After Update (for all above Data Operations) it is better to Refresh the Datacontrol.
I hope its Clear
Regards
Veena
Thank you veena for spending on me some time
Sign in to post your reply or Sign up for a free account.
Similar topics |
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
|
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
|
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...
|
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:
|
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...
| |
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...
|
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...
|
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:
|
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:
|
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...
|
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...
| |
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...
|
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...
|
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...
|
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...
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |