如何检查MS Acess中是否存在行 [英] How to check if Row exists in MS Acess

查看:106
本文介绍了如何检查MS Acess中是否存在行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以帮助我解决我的问题:

通过使用VB.NET,我想知道ms Access中是否存在一行.如果确实存在,则应将变量设置为pass = true,否则应为false.

我正在做一个学校申请程序,用户需要选择的是他们希望现在开始的年份,该数据库具有之前的10年等,并且每年10月添加新的年份来接受下一年的申请.

但是我遇到的问题是,如果有人选择在10月之前开始,例如2013年,我需要程序检查数据库,以查看2013年(第12行)的行是否退出,然后如果第12行(2013年)不接受,则接受申请存在给出错误消息.

我该如何实现呢?

我只需要知道如何检查行信息即可.
请有人帮忙

我已经尝试过此代码:

Can anyone kindly help me with my problem:

Through the use of VB.NET i would like to know if a row in ms access exists or not. If it does exist then it should set the variable pass = true else should be false.

Im doing a school application program and what user needs to select is the year they wish to start now the database has the previous 10 years etc and in October every year it adds the new year to accept application for the next year.

but the problem i have is if someone selects to start for e.g 2013 before october i needed the program to check the database to see if the row of 2013 (row 12) exits if it does then accept application if row 12 (2013) does not exist give error message.

How can i achieve this??

I just need to know how to check the row information..
Please can someone kindly help

i have tried this code:

 Try 
sql = ("SELECT * FROM Application") 
Dim dsx As New DataSet("app") 
Dim dax As New OleDb.OleDbDataAdapter 
dax = New OleDb.OleDbDataAdapter(sql, con)
 dax.Fill(dsx, "app")
 Dim tblapplications As DataTable 
tblapplication = dsx.Tables("app") 

If dsx.Tables("app").Rows.count = nothing Then 
msgbox("Year does not exist!")
 else
 call add()
 End If 
Catch ex As Exception MsgBox(ex.ToString)
 End Try 
End Sub 






急需帮助!!!

但这对我不起作用,不知道如何解决,所以有人可以帮忙


谢谢






Help needed urgently!!!

But this does not work for me, dont know how to fix, so can someone help


Thanks

推荐答案

首先,请阅读以下内容:
http://msdn.microsoft.com/en-us/library/system. data.datatable.rows.aspx [ ^ ]
http://msdn.microsoft.com/en-us/library/system. collections.arraylist.count.aspx [ ^ ]

First of all, read this:
http://msdn.microsoft.com/en-us/library/system.data.datatable.rows.aspx[^]
http://msdn.microsoft.com/en-us/library/system.collections.arraylist.count.aspx[^]

For i = To tblapplication.Rows.Count - 1
    'do something
Next


这篇关于如何检查MS Acess中是否存在行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆