|
When I click on the save button I get a error. Here is the code
Private Sub SaveRecord()
Dim pdsSaveRow As DataSet
Me.BindingContext.(Me.DsCustomerIndividual1, "Customers").EndCurrentEdit()
pdsSaveRow = DsCustomerIndividual1.GetChanges(DataRowState.Modified)
odaCustomerIndividual.Update(pdsSaveRow)
Me.DsCustomerIndividual1.Customers.AcceptChanges()
End SubPrivate Sub SaveRecord()
Dim pdsSaveRow As DataSet
Me.BindingContext(Me.DsCustomerIndividual1, "Customers").EndCurrentEdit()
pdsSaveRow = DsCustomerIndividual1.GetChanges(DataRowState.Modified)
odaCustomerIndividual.Update(pdsSaveRow)
Me.DsCustomerIndividual1.Customers.AcceptChanges()
End Sub
|
|
|
|
|
What's the error you are getting?
|
|
|
|
|
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.InvalidOperationException: Update requires a valid UpdateCommand when passed DataRow collection with modified rows.
at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping)
at System.Data.Common.DbDataAdapter.Update(DataSet dataSet, String srcTable)
at System.Data.Common.DbDataAdapter.Update(DataSet dataSet)
at How_To_1._1.Form1.SaveRecord() in C:\Documents and Settings\Harrison\My Documents\Visual Studio Projects\How-To 1.1\Form1.vb:line 504
at How_To_1._1.Form1.txtSave_Click(Object sender, EventArgs e) in C:\Documents and Settings\Harrison\My Documents\Visual Studio Projects\How-To 1.1\Form1.vb:line 514
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/microsoft.net/framework/v1.1.4322/mscorlib.dll
----------------------------------------
How-To 1.1
Assembly Version: 1.0.1780.42193
Win32 Version: 1.0.1780.42193
CodeBase: file:///C:/Documents%20and%20Settings/Harrison/My%20Documents/Visual%20Studio%20Projects/How-To%201.1/bin/How-To%201.1.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll
----------------------------------------
System
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
----------------------------------------
System.Drawing
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
----------------------------------------
System.Data
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/assembly/gac/system.data/1.0.5000.0__b77a5c561934e089/system.data.dll
----------------------------------------
System.Xml
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/assembly/gac/system.xml/1.0.5000.0__b77a5c561934e089/system.xml.dll
----------------------------------------
Accessibility
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/assembly/gac/accessibility/1.0.5000.0__b03f5f7f11d50a3a/accessibility.dll
----------------------------------------
Microsoft.VisualBasic
Assembly Version: 7.0.5000.0
Win32 Version: 7.10.3052.4
CodeBase: file:///c:/windows/assembly/gac/microsoft.visualbasic/7.0.5000.0__b03f5f7f11d50a3a/microsoft.visualbasic.dll
----------------------------------------
************** JIT Debugging **************
To enable just in time (JIT) debugging, the config file for this
application or machine (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
<configuration>
<system.windows.forms jitdebugging="true">
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the machine
rather than being handled by this dialog.
|
|
|
|
|
hi folks
i hope some experienced VB programmer will be able to help me here. I am using a free video capture control that i got from the net on a form in my application .its works fine saves some frames and emails them .
BUT is it possible to capture video in background when the application window is minimized .??
its not possible for me so far caz when i minimize the window i think the control loses focus or stops refreshing and the video display is not updated.
My requirement is to make this application as service or background application so that video capture happens in background when the application window is minimzed so that user can do other stuff..
any ideas suggestions .....??
thanx in advance
|
|
|
|
|
Hi,
I am having problems with using the DrawToDC of the
MSHTML.iHTMLElementRender in a VB.net application. For some reason I am
getting a "catastrophic error". I am basing the code on c# examples, and I cant figure out what I am doing wrong. From the C# posts it seems that
the drawtodc has a bug and you need to redifine it, so i followed their
advice and specified an interface as below but without any luck:
iHTMLElementRender Interface Code
Imports System
Imports System.Drawing
Imports System.Runtime.InteropServices
Imports mshtml
<ComVisible(True), ComImport(),
Guid("3050f669-98b5-11cf-bb82-00aa00bdce0b"), _
InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)> _
Interface IHTMLElementRender
Sub DrawToDC(<[In]()> ByVal hDC As IntPtr)
Sub SetDocumentPrinter(<[In](), MarshalAs(UnmanagedType.BStr)> ByVal
bstrPrinterName As String, <[In]()> ByVal hDC As IntPtr)
End Interface 'IHTMLElementRender
On the main form of the application I am have the folowing code when a button is clicked:
Dim objMSHTML As HTMLDocument
Dim objDocument As IHTMLDocument2
Dim ips As IPersistStreamInit
objMSHTML = New HTMLDocument()
ips = DirectCast(objMSHTML, IPersistStreamInit)
ips.InitNew()
objDocument =
objMSHTML.createDocumentFromUrl("http://www.google.com", String.Empty)
Do Until objDocument.readyState = "complete"
Application.DoEvents()
Loop
MsgBox(objDocument.body.outerHTML)
Dim bodyElement As IHTMLElement
Dim render As IHTMLElementRender
If objDocument.body.outerHTML <> Nothing Then
bodyElement = objDocument.body
render = bodyElement
Dim img As New Bitmap(600, 400)
Dim g As Graphics = Graphics.FromImage(img)
Dim memDC As IntPtr
memDC = g.GetHdc()
Try
render.DrawToDC(memDC)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End If
It seems like I am getting the HTML document just fine, is just that when I
try to use DrawToDC to get the application to print/send to the DC i Created
in memory, it causes the error.
From the dotnet newsgroups I was told I am not hosting MSHTMl fully and that might be the cause . I was told that I should use either the internetexplorer/webbrowser controls or the MSHTMl fully. I cannot find any source on the web on how to do this in vb.net I tried the following but this also failed.
Dim browser As New SHDocVw.InternetExplorer()
browser.Navigate("http://www.google.com")
Do Until browser.ReadyState = 4
Application.DoEvents()
Loop
Dim objDocument As IHTMLDocument2 = browser.Document
MsgBox(objDocument.body.outerHTML)
Dim bodyElement As IHTMLElement = objDocument.body
Dim render As IHTMLElementRender = bodyElement
Dim img As New Bitmap(600, 400)
Dim g As Graphics = Graphics.FromImage(img)
Dim memDC As IntPtr
memDC = g.GetHdc()
Try
render.DrawToDC(memDC)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
Here are the links to where I got the C# examples:
http://groups.google.com/groups?hl=en&lr=&threadm=a299f931.0406011058.43b92799%40posting.google.com&rnum=5&prev=/groups%3Fnum%3D100%26hl%3Den%26lr%3D%26q%3DDrawToDC%2B%2Bfailure
http://blogs.msdn.com/rfarber/archive/2004/10/12/240943.aspx
The article from this site with a C++ example:
http://www.codeproject.com/internet/htmlimagecapture.asp?msg=783713
Any ideas on what exactly I am doing wrong? Is it something to do with how I am hosting mshtml, or is it something with the iHTMLElementRender interface?
thanks
|
|
|
|
|
I need some help with printing. I can easily print a plain text document, but I can't seem to figure out how to print into Rich Text. This entire thing is driving me insane as I really need this for a big project of mine. I really need an example project with all the page setup, print preview, print dialog features... Why didn't Microsoft make this easy?
Please help me!
|
|
|
|
|
Dr. Pool wrote:
I really need an example project with all the page setup, print preview, print dialog features...
Try to check from:
1. Page setup.[^]
2. Print and print preview.[^]
Dr. Pool wrote:
need some help with printing
Try to check here[^] but it demonstrate in vb5, and you should convert it to vb.net
Let me know if it is working or not!!!
A thousand mile of journey, begin with the first step.
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
I want to create an application that has no user interface. The application will be started and stopped using the process class. Creating an app that starts with a Sub Main is no help because it still compiles as a Windows or Console app. Any ideas?
|
|
|
|
|
|
Thanks. I'll try this. I was hoping for something that doesn't create any UI overhead. I don't know if using this setting does or doesn't.
|
|
|
|
|
You might be want to create windows service application.[^] Let me know is this match what you need or not.
A thousand mile of journey, begin with the first step.
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
Thanks for the reply. I tried a service app but got a message saying it had to be installed and I didn't want to take that route. May I didn't try for long enough.
|
|
|
|
|
L.s.
I have written a program vb.net and i have compiled it in to an .exe
Part of this .exe is a module with one argument.
I want to run this .exe from the DOS prompt.
Actually, I want that certain module to be executed giving it an value for it's argument.
I hope someone can help me,
I really need an solution.
Best regards,
Steven
Steven de Vries
|
|
|
|
|
Steven de Vries wrote:
I want to run this .exe from the DOS prompt.
What type of application that you create in vb.net? Do you create console application. If so, try read this lab.[^] Let me know if it is match what you need or not.
A thousand mile of journey, begin with the first step.
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
I have a DataSet set up as an XML file and a DataGrid bound to that DataSet that displays all of the columns in the XML database except for three, one of those being the primary key. I want the user to be able to double click on a row in the DataGrid and have it display the entire record on another form. But I'm having trouble getting the data since the primary key isn't in the dataGrid. I tried using the CurrentRow index but it doesn't necessarily match the same row number of the DataSet, especially if it's been sorted. So how can I link the row selected in the DataGrid to the matching row in the DataSet?
I'm a newbie at DataGrids and DataSets so I've been searching for the answer to this for a few days. I found out this morning that the ASP.NET DataGrid has a property called DataKeys. Does the VB.NET DataGrid have something similar?
C code. C code run. Run code run!
|
|
|
|
|
Is there no way to do this in VB.NET? Basically all I'm looking for is a way to determine the primary key of the row that the user double clicked on in the DataGrid.
Thanks in advance!
C code. C code run. Run code run!
|
|
|
|
|
You have to use the BindingContext to determine the current dataviewrow. From there you can get the datarow and pull out the Primary Key. Ex:
Private Sub DataGrid1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.DoubleClick
Dim dvRow as DataRowView = Me.BindingContext(DataGrid1.DataSource, DataGrid1.DataMember).Current
Dim dRow as DataRow = dvRow.Row
MsgBox("dRow Primary Key: " & dRow.item("Key"))
End Sub
From what I've read, this may not work if you're using a filter to display your data.
C code. C code run. Run code run!
|
|
|
|
|
hi everyone
i need an urget urgent urgent help
well what i need help in is, that i want to develop a call card solution , let me exaplin simply, my customer will buy a card, then dial a number, this number asks him to insert the pin code, the authentication is done, then the system will give him a tone and he will dial is number!
ofcourse using .NET
well thats its!
so is there anyone can lead me to anything to start with, any link or code or tutorial and wwillllll be realllyyyy thankfulllll
Kind Regards
Mahmoud Manasrah
|
|
|
|
|
In my opinion, I guest that this is homework that you got from school. Most of our member help to the member that face the real problem in project and give the answer for the peiece of the problem in the project.
A thousand mile of journey, begin with the first step.
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
I'm not sure how to find freespace on a diskette. I've searched MSDN, but only found examples of VB6 and scripting examples.
I'm trying to find a VB.NET solution. Does anyone have any sample code where they look up how much space a file will take and then check how much space is available on the target drive the file is going to be transfered to?
Any help is appreciated.
Lost in the vast sea of .NET
|
|
|
|
|
Hello Kai!
Does anyone have any sample code where they look up how much space a file will take and then check how much space is available on the target drive the file is going to be transfered to?
I'm afraid my suggestion requires the .NET Framework 2.0 but with the new classes the solution is quite easy. Use the DriveInfo.AvailableFreeSpace [^] property to determine how much space is available to you. If it's at least the size of your file (to get that information you can use the FileInfo.Length [^] property) you call FileCopy [^].
Imports System.IO
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim MyDrive As DriveInfo = New DriveInfo("A")
Dim MyFile As FileInfo = New FileInfo("C:\boot.ini")
If MyDrive.AvailableFreeSpace >= MyFile.Length Then
FileCopy(MyFile.FullName, _
MyDrive.RootDirectory.ToString() + MyFile.Name)
End If
End Sub
End Class
If you're using the .NET Framework 1.1 it seems you will have to use the WMI (see Finding the Amount of Disk Space Available (Visual Basic)[^]).
Best regards
Dennis
|
|
|
|
|
Hi Dennis,
I'm going to keep this message, and reference it later when 2.0 is readily used. For now I used the following information that I found on freevbcode.com:
http://www.freevbcode.com/ShowCode.asp?ID=5588&NoBox=True
I created a class library using this code sample, and any programs I have that need this info can reference the class for info.
I will use the information you gave me to update the class library when our shop has gone to 2.0.
Thanks for the information
KreativeKai
Lost in the vast sea of .NET
|
|
|
|
|
I have an edit box called Login. How do I set the focus on Login at THE END of the string currently in Login? calling Login.SetFocus sets the cursor at the beginning of the string. I want it at the end.
Thank you,
Red Sunday
-----------------
http://www.zachcalvert.com
|
|
|
|
|
Try:
<br />
TextBox1.SelectionStart= TextBox1.Text.Length<br />
TextBox1.Focus()<br />
|
|
|
|
|
Try this code:
With txtLogin
.SelStart = 0
.SelLength = Len(.Text)
.SetFocus
End With
A thousand mile of journey, begin with the first step.
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|