Click here to Skip to main content
15,923,142 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Questioncreate MS access DB from VB Pin
mesho2-Mar-08 11:55
mesho2-Mar-08 11:55 
GeneralRe: create MS access DB from VB Pin
Dave Kreskowiak3-Mar-08 9:12
mveDave Kreskowiak3-Mar-08 9:12 
Generaldrawicon to listview Pin
benjj2-Mar-08 11:49
benjj2-Mar-08 11:49 
GeneralRe: drawicon to listview Pin
John_Adams3-Mar-08 0:57
John_Adams3-Mar-08 0:57 
GeneralSetup project in VIsaul Studio Pin
highjo2-Mar-08 11:27
highjo2-Mar-08 11:27 
GeneralRe: Setup project in VIsaul Studio Pin
Dave Kreskowiak3-Mar-08 4:09
mveDave Kreskowiak3-Mar-08 4:09 
GeneralRe: Setup project in VIsaul Studio Pin
highjo3-Mar-08 5:54
highjo3-Mar-08 5:54 
QuestionWhy do I sometimes get OleDb.OleDbException or ConstraintException for the same operation? Pin
David Mujica2-Mar-08 9:24
David Mujica2-Mar-08 9:24 
The background is that my program adds data to a MS-Access data-bound table programatically.

Here is how I am testing:

1) I test the error handling by adding a record that I know will violate the primary key and I receive the OleDb.OleDbException exception. (OK, I can deal with that ...)

2) I then perform a successful addition of a record. (Still OK ...)

3) I then re-test the error handling by adding a record that I know will violate the primary key and now I recieve the ConstraintException exception. (Huh ???)

4) Now after I continue to test the program I will receive the ConstraintException exception.

It also appears that if I don't do some sort of cleanup then when I try to add a row that I know is good, it continues to fail because it is trying to add the record that previously failed. To get around this I added RejectChanges and RemoveCurrent logic and now my applications seems to operate correctly under all testing conditions. I just don't feel confident that this is the correct way to handle the situation.

Why am I getting 2 different execptions for the exact same code execution ?

Also, please tell me the best way to handle the situation of key/constraint violation.

Why should I have to Reject changes or remove the row from the BindingSource ?

Thanks,
David

Rough code sample follows:
<br />
 Try<br />
<br />
  schedDR = CType(CType(Me.PP_ScheduleBindingSource.AddNew, DataRowView).Row, TCDataSet._PP_ScheduleRow)<br />
<br />
  schedDR.SchedDate = dTmp<br />
  schedDR.SiteID = sSite<br />
  schedDR.EmpID = sEmpID<br />
  schedDR.TimeOpen = sOpenTime<br />
  schedDR.TimeClose = sCloseTime<br />
<br />
  Me.PP_ScheduleBindingSource.EndEdit()<br />
  Me.PP_ScheduleTableAdapter.Update(Me.TCDataSet._PP_Schedule)<br />
<br />
Catch ex As OleDb.OleDbException<br />
  schedDR.RejectChanges()<br />
  MsgBox("caught dbException" + vbCrLf + ex.Message)<br />
<br />
Catch ex As ConstraintException<br />
  Me.PP_ScheduleBindingSource.RemoveCurrent()<br />
  MsgBox("Caught Constraint Exception" + vbCrLf + ex.Message)

AnswerRe: Why do I sometimes get OleDb.OleDbException or ConstraintException for the same operation? Pin
Dave Kreskowiak3-Mar-08 8:42
mveDave Kreskowiak3-Mar-08 8:42 
NewsNow I only get the ConstraintException error Pin
David Mujica4-Mar-08 3:49
David Mujica4-Mar-08 3:49 
GeneralExtracting Time Only From SQL EXPRESS Time UDT Using VB.NET Pin
AAGTHosting2-Mar-08 9:10
AAGTHosting2-Mar-08 9:10 
GeneralRe: Extracting Time Only From SQL EXPRESS Time UDT Using VB.NET Pin
pmarfleet2-Mar-08 9:22
pmarfleet2-Mar-08 9:22 
QuestionHow to disable Type inference for generic procedures ? Pin
Ky Nam2-Mar-08 6:25
Ky Nam2-Mar-08 6:25 
AnswerRe: How to disable Type inference for generic procedures ? Pin
Dave Kreskowiak3-Mar-08 4:03
mveDave Kreskowiak3-Mar-08 4:03 
GeneralHelp File Pin
parth.p2-Mar-08 1:00
parth.p2-Mar-08 1:00 
GeneralRe: Help File Pin
Smithers-Jones2-Mar-08 1:54
Smithers-Jones2-Mar-08 1:54 
GeneralRe: Help File Pin
parth.p2-Mar-08 3:29
parth.p2-Mar-08 3:29 
GeneralRe: Help File Pin
highjo3-Mar-08 6:24
highjo3-Mar-08 6:24 
GeneralRe: Help File Pin
parth.p3-Mar-08 6:48
parth.p3-Mar-08 6:48 
Questiondynamic crystal report - Withour DSN - back end ORACLE - vb 6.0? Pin
sejal_tank1-Mar-08 19:50
sejal_tank1-Mar-08 19:50 
GeneralCrytal Reports Active X Designer - error Pin
Anoop Brijmohun1-Mar-08 19:24
Anoop Brijmohun1-Mar-08 19:24 
GeneralRe: Crytal Reports Active X Designer - error Pin
Mitesh Darji3-Mar-08 2:07
Mitesh Darji3-Mar-08 2:07 
GeneralRe: Crytal Reports Active X Designer - error Pin
Anoop Brijmohun3-Mar-08 2:14
Anoop Brijmohun3-Mar-08 2:14 
QuestionRe: Crytal Reports Active X Designer - error Pin
scaldwe26-Mar-08 9:31
scaldwe26-Mar-08 9:31 
AnswerRe: Crytal Reports Active X Designer - error Pin
Anoop Brijmohun26-Mar-08 20:00
Anoop Brijmohun26-Mar-08 20:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.