|
I get the following error when I try to update my access table with a datagrid
An unhandled exception of type 'system.invalidoperation" occured in system.data.dll'
The code I am using looks like this:
If CODE_DataSet.HasChanges Then
Dim CON As New OleDbConnection(CONNECT_STRING)
Dim MY_SQL As String
Dim CMD As OleDbCommand
Dim DR As OleDbDataReader
Dim data_adapter As OleDbDataAdapter
Dim command_builder As OleDbCommandBuilder
Dim select_string As String = "SELECT TMP_ADMIN.QUOTE_LINE_NO, TMP_ADMIN.OPTION, TMP_ADMIN.PRODUCT_CODE, TMP_ADMIN.DESCRIPTION, TMP_ADMIN.QTY, TMP_ADMIN.UNIT_COST, TMP_ADMIN.SELL, TMP_ADMIN.TAG FROM TMP_ADMIN;"
CMD = New OleDbCommand(select_string, CON)
data_adapter = New OleDbDataAdapter(select_string, CONNECT_STRING)
data_adapter.TableMappings.Add("Table", CODE_TABLE)
command_builder = New OleDbCommandBuilder(data_adapter)
command_builder.GetUpdateCommand()
data_adapter.Update(CODE_DataSet)
End If
Any ideas? is there a better way to upgrade my MSAccess tables from a datagrid?
|
|
|
|
|
put those on start of class:
Dim CON As New OleDbConnection(CONNECT_STRING)
Dim MY_SQL As String
Dim CMD As OleDbCommand
Dim DR As OleDbDataReader
Dim data_adapter As OleDbDataAdapter
Dim command_builder As OleDbCommandBuilder
what for is this one?
<blink><font color=#FF0000>Dim select_string As String = "SELECT TMP_ADMIN.QUOTE_LINE_NO, TMP_ADMIN.OPTION, TMP_ADMIN.PRODUCT_CODE, TMP_ADMIN.DESCRIPTION, TMP_ADMIN.QTY, TMP_ADMIN.UNIT_COST, TMP_ADMIN.SELL, TMP_ADMIN.TAG FROM TMP_ADMIN;"</font></blink>
you should put that in MY_SQL string up there:
Dim MY_SQL As String="SELECT TMP_ADMIN.QUOTE_LINE_NO, TMP_ADMIN.OPTION, TMP_ADMIN.PRODUCT_CODE, TMP_ADMIN.DESCRIPTION, TMP_ADMIN.QTY, TMP_ADMIN.UNIT_COST, TMP_ADMIN.SELL, TMP_ADMIN.TAG FROM TMP_ADMIN<blink><font color=#FF0000>;</font></blink>" 'And without this one!!! i think...
The third part:
Cmd = New OleDbCommand(MY_SQL, CON)
data_adapter = New OleDbDataAdapter(select_string, CONNECT_STRING)
data_adapter.TableMappings.Add("Table", <blink><font color=#FF0000>CODE_TABLE</font></blink>)
command_builder = New OleDbCommandBuilder(data_adapter)
command_builder.GetUpdateCommand()
data_adapter.Update(CODE_DataSet)
End If
<blink>And i dont see annywhere that u have defined the "CODE_TABLE" variable.
I think i have helped you... Good luck
FeRtoll Software.net
--------------------
I fertoll@net.hr I
--------------------
|
|
|
|
|
In your TMP_ADMIN table, do you have a primary key field? Are you returning that field in your SELECT statement? If not, you'll have to make one to use it with a DataAdapter.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I adjusted the Tmp_Admin table and set quote_line_no to the primary key and am now getting this error. Any Ideas
An unhandled exception of type 'System.Data.DBConcurrencyException' occurred in system.data.dll
Additional information: Concurrency violation: the UpdateCommand affected 0 records.
|
|
|
|
|
I ran into that once before. I can't remember what I did to cause it though...
Hmmmm....Well, let's start with cleaning up your code a bit:
If CODE_DataSet.HasChanges Then
Dim select_string As String = "SELECT TMP_ADMIN.QUOTE_LINE_NO, TMP_ADMIN.OPTION, " & _
"TMP_ADMIN.PRODUCT_CODE, TMP_ADMIN.DESCRIPTION, TMP_ADMIN.QTY, TMP_ADMIN.UNIT_COST, " & _
"TMP_ADMIN.SELL, TMP_ADMIN.TAG FROM TMP_ADMIN;"
Dim data_adapter As New OleDbDataAdapter(select_string, CONNECT_STRING)
Dim command_builder As New OleDbCommandBuilder(data_adapter)
data_adapter.TableMappings.Add("Table", CODE_TABLE)
data_adapter.Update(CODE_DataSet)
CODE_DataSet.Clear()
data_adapter.Fill(CODE_DataSet)
End If
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
THANKS
THAT WORKED GREAT!!
I APPRECIATE THE HELP!!
|
|
|
|
|
No problem!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I am using a treeview/listview combination. I want to use the treeview selection to populate what appears in the listview. As an additional note, the treeview will either display a list of companies or trades based on a radio button control.
Does anyone have a suggestion as to which event I should use to accomplish this?
I have tried the following;
AfterSelect event - the event appears to kickoff twice - once for the item that it is deselecting and one for the item it is selecting. When switching radio buttons, the event seems to run for each previous item in the list.
BeforeSelect event - does not know which node is selected
Click event - shows me the the last node selected
Any assistance is appreciated - Thank you in advance.
|
|
|
|
|
I just wanted to update this post in case anyone hapens to run across it.
When doing a treeview.nodes.clear - the afterselect event is actually kicking off for each previous node in the tree. Therefore if you are at node 1000 and you do a clear - the afterselect event kicks off that many times. To resolve the issue - you set the selectednode = nothing . . . see below for example.
If rdoByTrade.Checked Then
'Clear Listview
ListView1.Items.Clear()
ListView1.Columns.Clear()
TreeView1.SelectedNode = Nothing
TreeView1.Nodes.Clear()
'Load Treeview
LoadTree()
End If
In the afterselect event - I only process if treeview.selectednode.text <> nothing.
If TreeView1.SelectedNode.Text <> Nothing Then
LoadListView()
End If
|
|
|
|
|
I have written a small utility which works perfectly fine when it is launched from my local hard disk, but if it is run from a network location, it immediately throws the following error:
Common Language Runtime Debugging Services
Process id=0xd74 (3444), Thread id=0xcb8 (3256)
Click OK to terminate the application
Click CANCEL to debug the application
As a VB.NET newbie, I don't know how to catch this - or even better - make it run from the network location.
Any advice is really appreciated.
|
|
|
|
|
One of the things that you can do is adjust the security settings in the client computer.
In Administrative tools\Microsoft .Net Framework 1.1 Configuration and adjust the Local Intranet Zone Security.
Hope it helps
|
|
|
|
|
Hi All,
I'm generating a fileName based on the current date/time and would like to simply prepend leading zeros to the month, day, hours, minutes, and seconds if they're less than 10. This seems so simple and yet I haven't seen a function to do it (in VBScript).
Of course, I could write my own, but I'd rather not if MS provided one that I've just missed. Do any of you know if this already exists?
In VB6, I would just write something like:
strFinal = Format( nNum, "00" )
In C/C++, something like:
sprintf( strFinal, "%02d", nNum );
(Please forgive any synatx errors...it's been a while since I wrote C )
Any help is greatly appreciated.
Thanks!
Justin
|
|
|
|
|
Yeah, VBScripts formatting leaves much to be desired. But, there is a very easy solution to the problem.
Function FLZ(length, number)
Dim temp
' Generate a string of zeros the length we need, then append the number
' length = 5 and number = 232 would be "00000232"
temp = String( length, "0" ) & number
' Grab the length of the string we need to return
' length = 5 would return "00232"
FLZ = Right( temp, length )
End Function
Now all you have to do is call this for each number you want to format:
Filename = FLZ(2, Month) & FLZ(2, Day) & "-" & FLZ(2, Hour) & FLZ(2, Minute) & FLZ(2, Second)
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks, Dave! That works perfectly and you saved me the hassle (albeit minor ) of writing it myself. Much appreciated.
|
|
|
|
|
I have a windows form application written in VB.NET 2005 which opens Excel, imports a text file into a worksheet and e-mails it to the end-user.
Everything works fine when it is on my own system, but when I put the executable file on the server along with all the other files in the bin\release folder, I get the following error:
HPtoExcel has encountered a problem and needs to close. We are sorry for the inconvenience.
I had the following references in my program and it ran fine on my system:
Microsoft Excel 11.0 Object Library
Microsoft Office 11.0 Object Library
Microsoft Visual Basic for Applications Extensibility
I added the following references and still receive the error:
Microsoft.Office.Tools.Common
Microsoft.Office.Tools.Excel
Microsoft.VisualStudio.Tools.Applications.Runtime
OLE Automation
The server does not have Excel on it, but my system does. I'm double clicking on a shortcut on my desktop to the exe on the server. Is there a way to get around loading Excel on the server?
Any help is appreciated.
Lost in the vast sea of References
Lost in the vast sea of .NET
-- modified at 14:14 Monday 6th March, 2006
|
|
|
|
|
KreativeKai wrote: The server does not have Excel on it
There's your problem!
KreativeKai wrote: Is there a way to get around loading Excel on the server?
No, there isn't. How is your server code going to call Excel if it's not installed on the server?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I called Microsoft using one of our MSDN incidents. Basically Office is designed for interactive usage and they do not recommend automating it with an unattended application. Like you said, you need to have Excel installed, but they do not support Office being installed on a server because it is not designed to work on a server and cause unexpected results.
Here is a link showing their “Not supported” statement and their “at your own risk” workarounds:
http://support.microsoft.com/?id=257757
I used the workaround towards the end of the article related to “How to configure Office applications to run under the interactive user account” and I put the application on a client PC using scheduled tasks instead of on a server.
Thanks for you help Dave!!
Lost in the vast sea of .NET
|
|
|
|
|
Hallo, I'd like to to get help on the following subject:
I use a BackgroundWorker control in a form and i'd like to show intermediate results from the BackgroundWorker in a control on the same form (before it has finished its work). I tried accessing the control by reference but an exception occurred stating that the control's property (Text) cannot be changed from another thread.
thank you.
|
|
|
|
|
Make an event to which your form that will display the progress will listen.
And then fire that event from the working thread whenever you wan't to update the status (you can pass the status information in the event arguments)
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
It's correct. You can't access UI controls from any other thread other than the one that created the control (known as the UI thread).
The BackgroundWorker exposes a ProgressChanged event that you can use to update your controls. Of course, your worker code has to be able to send some kind of usuable progress!
' Setup the BackgroundWorker object and start the work somewhere...
BackgroundWorker1.WorkerReportsProgress = True
BackgroundWorker1.WorkerSupportsCancellation = True
BackgroundWorker1.RunWorkerAsync()
Private Sub BackgroundWorker1_DoWork(ByVal sender As Object, ByVal e As DoWorkEventArgs) Handles BackgroundWorker1.DoWork()
' Get a reference to the BGW that called this
Dim bgw As BackgroundWorker = CType(sender, BackgroundWorker)
' Do some long running task about a million times...
For I As Integer = 1 to 1000000
' Check to see if we've been cancelled
If bgw.CancellationPending Then
e.Cancel = True
Exit For
End If
' Do something useful here...
bgw.ReportProgress(i / 10000) ' Reduce i to the range of 0 to 100.
Next
e.Result = whatever ' Return whatever the result of this work is supposed to be.
End Sub
Private Sub BackgroundWorker1_ProcessChanged(ByVal sender As Object, ByVal e As ProgressChangedEvent) Handles BackgroundWorker1.ProgressChanged
' Do something usefull with the progress
ProgressBar1.Value = e.ProgressPercentage
End Sub
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
thank you for your answer, it was really helpful.
|
|
|
|
|
Hello. I'm writing a program to store passwords. I would like to allow the user the option of sending the username and passwords to the website by just clicking a button. Can anyone help me? Thanks in advance.
|
|
|
|
|
In most cases, you can't do that. You'll have to load the login page, find (NOT EASY!), then fill in the fields with the data, then submit the login page back to the server. You can't just send a username and password to the web server and expect it to work. It just doesn't work that way.
On top of that, this is already built into Internet Explorer...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-- modified at 14:52 Monday 6th March, 2006
|
|
|
|
|
Okay I realize this is probably quite an easy questions however it has me stumped right now. I am trying to use a rich text box to display output data in three columns. The columns are lined up using tabs and everything looks great on the screen. The problem is when I go to print the data all of my tabs are lost! I have used vbtab and chr(9) coding. I don't want to hard code spaces since that way is very unpredicable and can cause problems if the font every gets changed.
Can someone please explain what the hell I am doing wrong?
Thanks
|
|
|
|
|
That depends on how you're printing the contents of the box... An explaination of how you're doing this might help.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|