|
If you think my answer is perfect then do vote for my message.
Cheers,
Suresh
|
|
|
|
|
... and where am I supposed to do this ?
|
|
|
|
|
Hello all,
I am running VB.Net 2005 and connecting to a Access 2003 DB. For some reason when I add a record and try to save it I get the following error...
Concurrency violation: the UpdateCommand affected 0 of the expected 1 records....yet when I close the progarm and open it back up the record is save but without data (Primary Key only)...I can then write to the data with no problem.
I have several routines that write to different tables and this problem happens on each of them. I am a newbie to VB so you many need to dummy it down for me. Thanks in advance for any help you can give!! I am totally lost on this one.
|
|
|
|
|
In order to use DataAdpaters, every table involved with the adapter has to have a primary key. This is the biggest newbie mistake.
Without seeing your code that queries and updates the database, it's impossible to tell you what wrong.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
Hey Dave, thank you for the reply. I am using one adapter per table and I am updating one table at a time (and it does have a primary key). Here is an example of when I am running the update in my code....Pat01Surgery is the name of my table and it is in the dataset AnesDataSet
'Update the record
Try
Me.Validate()
Me.Pat01SurgeryBindingSource.EndEdit()
Me.Pat01SurgeryTableAdapter.Update(Me.AnesDataSet.Pat01Surgery)
Catch ex As Exception
MsgBox("Update of Surgury Table Failed")
End Try
Note that I don't get to the catch exception...I get my error on the End Edit line.
Any ideas?
-- modified at 13:12 Thursday 19th April, 2007
|
|
|
|
|
What about the code that creates the TableAdapters? A bogus SQL SELECT statement could screw this up.
.... Or did you use the designer to create your database code?? <wince> </wince>
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
I used the designer, I just drug my tables over to the form one at a time and it created my adapters for me.
|
|
|
|
|
Here's the problem with using the Designer to do your database code. It's increased the level of difficulty in supporting problems like this about 10 fold. This is because the designer just wrote a bunch of code for you that you can't find and don't know anything about, let alone why the code works, or in most cases, DOESN'T work!
There's quite a number of possibilities that may cause this error. See this[^] for a good list of them.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
Alright, thanks Dave I will take a look at that page and hopefully it will help me find my problem. Have a great day!
|
|
|
|
|
Ok, I got it. I had to put this in my code after my update line...
OleDbDataAdapter.Fill(mydataset.tablename)
pretty much just needed to refill the dataset. I am doing it for each table that I am updating.
I hope this helps someone else one day.
|
|
|
|
|
I wonder if anyone could help me solve this.
I am using VB.Net 2003 with Crystal Reports 10.
Example.
I have a VB form that has values in the text boxes. At the moment I am able to transfer these values to a Crystal Report via code like below
paramField = New ParameterField
discreteVal = New ParameterDiscreteValue
paramField.ParameterFieldName = txtSomething.text
' Set the first discrete value and pass it to the parameter
discreteVal.Value = param_value
paramField.CurrentValues.Add(discreteVal)
ParamFields.Add(paramField)
etc etc
The question is how you can capture values that are held in the datagrid e.g.
Name Dept Age
Alan Accounts 21
Sue Sales 27
Jim Accounts 35
Linda IT 30
Would it be something similar or is there a specific way of capturing values.
|
|
|
|
|
Are you looking at looping through every row of the datagrid? or get the value when a row/cell is selected?
|
|
|
|
|
I would be looping through the datagrid as the values are already there. I thought about putting values in an array and populating it that way. How would I then be able to populate the Crystal Report? Or is there a better way of doing this?
On the Crystal Report I put the values into a parameter field.
|
|
|
|
|
You can probably have a look at this[^]. The last solution shows you how to loop thru each record. The code is in c# I am sure you can just convert it to vb.net
|
|
|
|
|
i need to make pop3 server that can access and download email from http request. this program masu work with email client outlook express.
maybe its like Ypops ! but its not use pop3 its use http request. any pop3 request from outlook will be translate as http request.
Its like download our email via web.
anyone can help ... plisss i want to make it using visual basic 6
|
|
|
|
|
dmid wrote: plisss i want to make it using visual basic 6
That's probably going to kill off any volunteers. VB6 is quite old and isn't supported by Microsoft anymore. I haven't used it in about 6 years, since .NET came out.
The biggest problem you're going to have is that you need to write a HTTP client into your server that can parse and handle the web page your getting the mail from. The issue is when that web page changes, it'll pretty much destroy all the work you put into parsing the existing page.
You'll also have to handle paging on that page, where the number of emails exceed a certain number. You'll have to handle removing messages from the server and downloading images in the emails and downloading attachments.
And that doesn't even touch the POP3 side of your server.
The bottom line is this is NOT going to be any easy project. It'll probably take you about as long to write it as it'll take for your web-based email service to change the page layout on you! Or, even move the thing to a Java-based application, forcing you to completely scrap what you're doing anyway.
Today, most email providers have both SMTP/POP3 and a web-based client. So why all the work for something that's more-than-likely a redundent application?
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
Hello all,
Is there any way to catch the key pressed in VB.net 2005?
I want to create a simple form that will pop up a message when it detects any key pressed when it starts.
Thank you
|
|
|
|
|
Any key that is pressed in your application, or any key that is press system-wide? If it's system wide, then you're talking about a global keyboard hook. Just search the articles for "keyboard hook" and you'll find a bunch of examples.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
Hmm... ok I will try that.
However, I was just wondering why is the override onKeyPress doesn't work in visual basic.net 2005?
I was using the same function in 2003.
|
|
|
|
|
It does work. You have to set your form's KeyPreview property to true in order for the form key events to work. But, they will only work if your application has the input focus. They won't work for a global keyboard hook.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
HAHAHA... Thanks Dave.
|
|
|
|
|
I want to call functions of a C++ dll but Im having problems. The function in C++ in declared the next way:
__declspec( dllexport )int Initialize(char * in_szStatusLoc);
My code in Basic is:
Private Declare Function Initialize Lib "C:\Archivos de Programa\CallRex\CallrexApi.dll" (ByVal inszStatusLoc As String) As Integer
Private Sub Form_Load()
Dim error As Integer
error = Initialize("192.168.100.130")
End Sub
I alway get an error that says: Run-time error 49, Bad DLL calling convention.
What can be wrong?
|
|
|
|
|
Try changing the Declare to:
Private Declare Function Initialize Lib "callrexApi.dll" (ByRef inszStatusLoc As String) As Long
The full path to the .DLL was removed to allow for having the .DLL file in the same folder as the application .EXE without knowing what that path is ahead of time.
The Integer at the end was changed to a Long because your C++ header shows that it's returning an int , which is a 32-bit signed integer. In VB6, the equivilent datatype is a Long, not an Integer. Integer in VB6, IIRC, is a 16-bit signed integer.
My VB6 is really rusty; I haven't used it in about 6 years.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
Thank you for your answer. I just try it and I got exactly the same result. What else can be wrong?
|
|
|
|
|
Try changing the ByRef in your Declare back to ByVal.
I didn't notice this before, but I think the calling convention in the C++ header is wrong for use with VB6:
__declspec( dllexport )int Initialize(char * in_szStatusLoc);
I seem to remember something about VB6 expecting the _stdcall convention, not __declspec . If you have control over the source code for this .DLL, you'll have to change the call to _stdcall . If you can't change that .DLL, you'll have to write a wrapper around it in C++, that exposes _stdcall decorated functions and calls the __declspec version of the .DLL for VB.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|