| | |
Using RecordsAffected as a parameter
Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved |
VB.NET Syntax (Toggle Plain Text)
SearchString = "SELECT * FROM Breakdown WHERE BFrom = " & txtFrom.Text ' & " AND BTo = " & txtTo.Text Dim Con As New OleDbConnection(BCalc_ConnectionString) Dim Search As New OleDbCommand(SelectSearchString, Con)
I want to stop users from being able to save a duplicate record in my Access database. I thought of using RecordsAffected, but I can't figure out how to get it to work.
That's how I've started. I want to be able to use the result of the RecordsAffected as a parameter in an IF statement so that
VB.NET Syntax (Toggle Plain Text)
IF Search.records affected = 0 THEN Insert records ELSE Display msgbox telling user that duplicate records aren't allowed.
Please Help...
see this code :
VB.NET Syntax (Toggle Plain Text)
Dim cn As OleDbConnection Dim cmd As OleDbCommand Dim dr As OleDbDataReader cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\MyDB.mdb;") cn.Open() cmd = New OleDbCommand("SELECT * FROM Breakdown WHERE BFrom = '" & txtFrom.Text & "'", cn) dr = cmd.ExecuteReader If dr.Read() MsgBox "Matching Records Found" 'write whatevr code u want here Else MsgBox "Data not found" End If dr.Close() cn.Close()
![]() |
Similar Threads
Other Threads in the VB.NET Forum
- Previous Thread: Need Help for Search function button
- Next Thread: running script
| Thread Tools | Search this Thread |
.net .net2008 2008 access add advanced application array basic beginner browser button buttons center click code combo cpu cuesent data database datagrid datagridview date datetimepicker designer dissertation dissertations dissertationtopic employees excel exists fade filter forms generatetags html images input intel internet listview map mobile module monitor msaccess mysql net number objects open pan panel pdf picturebox picturebox2 port position print printing printpreview regex remove reuse right-to-left save search searchvb.net serial settings shutdown socket sqldatbase sqlserver storedprocedure survey temperature textbox timer timespan transparency txttoxmlconverter user usercontol vb vb.net vba vbnet vista visual visualbasic visualbasic.net visualstudio.net web winforms wpf wrapingcode xml year






