473,387 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 21885

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
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
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
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
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
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
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
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
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
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
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
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...

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.