| | |
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 .net2005 30minutes 2005 2008 access account arithmetic array basic binary bing button buttons c# center check code combobox component connectionstring convert crystalreport data database databasesearch datagrid datagridview design dissertation dissertations dissertationthesis dropdownlist excel file-dialog folder ftp generatetags google gridview hardcopy image images inline insert intel internet listview mobile monitor ms net networking output passingparameters peertopeervideostreaming picturebox picturebox1 plugin port print printing problem problemwithinstallation project reports" save savedialog searchbox searchvb.net select serial server soap sql table tcp text textbox timer toolbox trim update updown user usercontrol vb vb.net vb.netcode vb.netformclosing()eventpictureboxmessagebox vb2008 vbnet view visual visualbasic visualbasic.net visualstudio visualstudio2008 web wpf






