Advertisement

05.07.2008 at 06:12PM PDT, ID: 23384775
[x]
Attachment Details

SIngle Insert or Update statement - ADO.Net

Asked by mpdillon in .Net Editors & IDEs, Miscellaneous Web Development, Programming for ASP.NET

Tags: ADO.NET

In VB6 using MDAC 2.8 I could do a single select statement that would act as either an Insert or an update. Is there a way to do this in ADO.net?
My old VB6 code
Dim dbData As New ADODB.Connection
Dim rs1 As New ADODB.Recordset
Dim strParm As String
Dim strCusNo As String
'
strParm = "Provider=SQLOLEDB; Data Source=SQL2000; Initial Catalog=DATA_01; User ID=UserName; Password=password"
dbData.Open strParm
'
strParm = "Select CusNo from CusFil Where CusNo = '" & strCusNo & "'"
rs1.Open strParm, dbData, adOpenStatic, adLockOptimistic, adCmdText
If rs1.BOF And rs1.EOF Then
    rs1.AddNew
Else

End If
With rs1
    !CusNo = strCusNo
    .Update
End With
rs1.Close
'
Set rs1 = Nothing
dbData.Close
Set dbData = Nothing

Is there an ADO.Net equivalent?

thanks,
patStart Free Trial
[+][-]05.07.2008 at 10:35PM PDT, ID: 21522523

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: .Net Editors & IDEs, Miscellaneous Web Development, Programming for ASP.NET
Tags: ADO.NET
Sign Up Now!
Solution Provided By: jpaulino
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628