473,486 Members | 1,862 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to check Eof in VB.Net ?


Hi,

I want to check whether the record exist or not based on my query, so i'll
be using OleDbCommand.
What is the best way to check on a huge table ? I used to write like this in
VB6.0...

---------------------------------------------------
Public Function SaveOrUpdate() As Boolean
sSQL = "SELECT * FROM AdmAllergy WHERE " & _
" CompanyCode = " & mQuotedStr(mCompanyCode) & _
" AND BranchCode = " & mQuotedStr(mBranchCode) & _
" AND Code = " & mQuotedStr(sCode)
Set oRs = TmpAdoSet(sSQL)
With oRs
If .EOF And .BOF Then
.AddNew
.Fields("CompanyCode") = Trim(mCompanyCode)
.Fields("BranchCode") = Trim(mBranchCode)
.Fields("Code") = Trim(sCode)
.Fields("CreatedBy") = Trim(mUserId)
Else
.Fields("EditedBy") = Trim(mUserId)
.Fields("EditedDate") = Format(Now, "yyyy-mm-dd hh:mm:ss")
End If
.Fields("Name") = Trim(Name)
.UpdateBatch
.Close
End With
SaveOrUpdate = True
Set oRs = Nothing
End Function
---------------------------------------------------

So, how do i write in VB.Net ? Want to open check record exist or not. If
exist then update other fields
or else add new record. I prefer to use OleDbCommand.

Any Help ?

Regards
Nov 20 '05 #1
6 21900

Hi,

I want to check whether the record exist or not based on my query, so i'll
be using OleDbCommand.
What is the best way to check on a huge table ? I used to write like this in
VB6.0...

---------------------------------------------------
Public Function SaveOrUpdate() As Boolean
sSQL = "SELECT * FROM AdmAllergy WHERE " & _
" CompanyCode = " & mQuotedStr(mCompanyCode) & _
" AND BranchCode = " & mQuotedStr(mBranchCode) & _
" AND Code = " & mQuotedStr(sCode)
Set oRs = TmpAdoSet(sSQL)
With oRs
If .EOF And .BOF Then
.AddNew
.Fields("CompanyCode") = Trim(mCompanyCode)
.Fields("BranchCode") = Trim(mBranchCode)
.Fields("Code") = Trim(sCode)
.Fields("CreatedBy") = Trim(mUserId)
Else
.Fields("EditedBy") = Trim(mUserId)
.Fields("EditedDate") = Format(Now, "yyyy-mm-dd hh:mm:ss")
End If
.Fields("Name") = Trim(Name)
.UpdateBatch
.Close
End With
SaveOrUpdate = True
Set oRs = Nothing
End Function
---------------------------------------------------

So, how do i write in VB.Net ? Want to open check record exist or not. If
exist then update other fields
or else add new record. I prefer to use OleDbCommand.

Any Help ?

Regards
=====================
Clock's wrong
=====================
Nov 20 '05 #2
Cor
Hi Itsme,
I think there are many ways, that depends on the way you use ADO.net.
The code you are now using is probably ado 2.6 or something.
In VB.net is used Ado.net it is a totaly different approach.
"Datasets, dataview, datarows and no recordsets."

I think that the best place to ask a question like this is in the
public dotnet adonet newsgroup.

I hope you have success
Cor
Nov 20 '05 #3
Thanks cor,
i've done that. desperately waiting for an answer

Regards

"Cor" <no*@non.com> wrote in message
news:3f**********************@reader22.wxs.nl...
Hi Itsme,
I think there are many ways, that depends on the way you use ADO.net.
The code you are now using is probably ado 2.6 or something.
In VB.net is used Ado.net it is a totaly different approach.
"Datasets, dataview, datarows and no recordsets."

I think that the best place to ask a question like this is in the
public dotnet adonet newsgroup.

I hope you have success
Cor

Nov 20 '05 #4
try desperately setting your system clock back to normal time.
"ItsMe" <it*******@yahoo.com> wrote in message
news:OM**************@TK2MSFTNGP09.phx.gbl...
Thanks cor,
i've done that. desperately waiting for an answer

Regards

"Cor" <no*@non.com> wrote in message
news:3f**********************@reader22.wxs.nl...
Hi Itsme,
I think there are many ways, that depends on the way you use ADO.net.
The code you are now using is probably ado 2.6 or something.
In VB.net is used Ado.net it is a totaly different approach.
"Datasets, dataview, datarows and no recordsets."

I think that the best place to ask a question like this is in the
public dotnet adonet newsgroup.

I hope you have success
Cor


Nov 20 '05 #5
Use OleDBCommand.ExecuteScalar and query the count. If the count of your
query is non-zero, it means the record exists. Then use
OleDbCommand.ExecuteNonQuery to insert a new record.

Alternatively, use DataSets !! Well, I would recommend that you first
understand ADO.Net before you embark on using it. It is different from
ADO2.7 by quite a margin both in architecture and style of programming and
needs special attention.

"Daniel Bass" <da********@NOSPAMpostmaster.co.uk> wrote in message
news:OD**************@TK2MSFTNGP09.phx.gbl...
try desperately setting your system clock back to normal time.
"ItsMe" <it*******@yahoo.com> wrote in message
news:OM**************@TK2MSFTNGP09.phx.gbl...
Thanks cor,
i've done that. desperately waiting for an answer

Regards

"Cor" <no*@non.com> wrote in message
news:3f**********************@reader22.wxs.nl...
Hi Itsme,
I think there are many ways, that depends on the way you use ADO.net.
The code you are now using is probably ado 2.6 or something.
In VB.net is used Ado.net it is a totaly different approach.
"Datasets, dataview, datarows and no recordsets."

I think that the best place to ask a question like this is in the
public dotnet adonet newsgroup.

I hope you have success
Cor


Nov 20 '05 #6
Besides using datasets as previiously mentioned, (which are quite helpful
and reflect that of ADO 2.x's Recordset Object) learn to use Enumerations
within datasets as well. You'll find your development time is cut down
(especially with typed datasets) when you use things like for each
statements, which will be helpful to you in more ways than you know.

Also, the dataset object (generated or not) exposes a ton of properties that
can do every concievable thing you want, including DataRelationships which I
think are one of the most powerful tools you can have.

Hope it helps,
CJ
"ItsMe" <it*******@yahoo.com> wrote in message
news:OM**************@TK2MSFTNGP09.phx.gbl...
Thanks cor,
i've done that. desperately waiting for an answer

Regards

"Cor" <no*@non.com> wrote in message
news:3f**********************@reader22.wxs.nl...
Hi Itsme,
I think there are many ways, that depends on the way you use ADO.net.
The code you are now using is probably ado 2.6 or something.
In VB.net is used Ado.net it is a totaly different approach.
"Datasets, dataview, datarows and no recordsets."

I think that the best place to ask a question like this is in the
public dotnet adonet newsgroup.

I hope you have success
Cor


Nov 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
4157
by: Craig Bailey | last post by:
Someone please explain what alternate universe I fell into this afternoon when PHP started telling me that 2 doesn't equal 2. Not sure about you, but when I run this, it tells me 59001.31 doesn't...
2
3203
by: Askari | last post by:
Hi, How do for do a "select()" on a CheckButton in a menu (make with add_checkbutton(....) )? I can modify title, state, etc but not the "check state". :-( Askari
2
2419
by: Edward | last post by:
The following html / javascript code produces a simple form with check boxes. There is also a checkbox that 'checks all' form checkboxes hotmail style: <html> <head> <title></title> </head>...
7
29843
by: Tony Johnson | last post by:
Can you make a check box very big? It seems like when you drag it bigger the little check is still the same size. Thank you, *** Sent via Developersdex http://www.developersdex.com ***...
2
27707
by: Travis.Box | last post by:
I have an MS Access userform with 16 Check Boxes. Each of the checkboxes has a different option value, which coincides with the Check Box name (eg. cb01.OptionValue = 1). At the bottom of the...
1
4239
by: scprosportsman | last post by:
Please help guys, i am trying to set up a database here at work and im fairly new to access in terms of writing functions and queries and stuff. I have 2 different places on my design that will...
2
3577
by: Chris Davoli | last post by:
How do you enable a check box in the GridView. I selected Checkbox Field in the Columns of the GridView, and the check box shows up in the Grid view, but it is disabled. How do I enable it so I can...
16
5630
by: Brian Tkatch | last post by:
Is there a way to check the order in which SET INTEGRITY needs to be applied? This would be for a script with a dynamic list of TABLEs. B.
5
11627
by: starke1120 | last post by:
Im creating a check in – check out database for RF guns. I have a table that contains models. ID (primary key) Model A table that contains Gun Details ID (primary key) Model_id...
1
2397
by: ghjk | last post by:
my php page has 7 check boxes. I stored checked values to database and retrive as binary values. This is the result array Array ( => 0 => 1 => 0 => 1 => 0 => 0 => 1 ) 1 means checked....
0
7094
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,...
0
7173
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6839
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5427
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,...
0
4559
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3066
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...
0
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
598
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
259
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...

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.