|
Is there any way to change the original value in the DataRow?
DataRow.Item(0) may have modified/current value and its original value. I need to change its original value like row.Item("ColumnName", DataRowVersion.Original) = "NewValue". But this property is for read only any.
Ideas?
I have found the way but I don't like it and it looks like a hack.
Here's the code:
<br />
Public Function SetRowOriginalItemValue(ByVal primaryKeyColumn As DataColumn, ByVal key As Object, ByVal editColumn As DataColumn, ByVal value As Object) As Boolean<br />
'Utils.Assert.ArgumentCheckForNullReference(primaryKeyColumn, "primaryKeyColumn")<br />
'Utils.Assert.ArgumentCheckForNullReference(key, "key")<br />
'Utils.Assert.ArgumentCheckForNullReference(editColumn, "editColumn")<br />
'Utils.Assert.ArgumentCheckExpectedType(key, primaryKeyColumn.DataType)<br />
'Utils.Assert.ArgumentCheckExpectedType(value, editColumn.DataType)<br />
Dim t As DataTable = editColumn.Table<br />
Dim d As DataSet = t.DataSet<br />
Dim s As New IO.MemoryStream<br />
d.WriteXml(s, XmlWriteMode.DiffGram)<br />
s.Seek(0, IO.SeekOrigin.Begin)<br />
Dim doc As New Xml.XmlDocument<br />
doc.Load(s)<br />
Dim nsmgr As Xml.XmlNamespaceManager = New Xml.XmlNamespaceManager(doc.NameTable)<br />
nsmgr.AddNamespace("diffgr", "urn:schemas-microsoft-com:xml-diffgram-v1")<br />
nsmgr.AddNamespace("my", d.Namespace)<br />
Dim xp As String = String.Format(New Globalization.CultureInfo("en-US"), _<br />
"/diffgr:diffgram/diffgr:before/my:{0}[starts-with(@diffgr:id, '{0}')]/my:{1}[text()='{2}']/../my:{3}/node()", _<br />
t.TableName, primaryKeyColumn.ColumnName, key, editColumn.ColumnName)<br />
Dim n As Xml.XmlNode = doc.DocumentElement.SelectSingleNode(xp, nsmgr)<br />
If Not n Is Nothing Then<br />
n.Value = value<br />
d.Clear()<br />
d.ReadXml(New IO.StringReader(doc.InnerXml), XmlReadMode.DiffGram)<br />
Return True<br />
End If<br />
Return False<br />
End Function<br />
<br />
''''''''''''''''''''<br />
<br />
Sub SetRowOriginalItemValueTest()<br />
Dim d As New DistrictSet<br />
Dim row As DistrictSet.DistrictsRow<br />
row = d.Districts.NewDistrictsRow<br />
row.DistrictId = 109901<br />
row.DistrictName = "Orange County"<br />
d.Districts.AddDistrictsRow(row)<br />
d.AcceptChanges()<br />
<br />
d.Districts(0).DistrictName = "West Coast"<br />
<br />
Diagnostics.Trace.WriteLine("Current: " & d.Districts.Item(0)("DistrictName"))<br />
Diagnostics.Trace.WriteLine("Original before SetRowOriginalItemValue(): " & d.Districts.Item(0)("DistrictName", DataRowVersion.Original))<br />
<br />
SetRowOriginalItemValue(d.Districts.DistrictIdColumn, 109901, d.Districts.DistrictNameColumn, "Northeast")<br />
<br />
Diagnostics.Trace.WriteLine("Original after SetRowOriginalItemValue(): " & d.Districts.Item(0)("DistrictName", DataRowVersion.Original))<br />
End Sub<br />
Output is:
Current: West Coast
Original before SetRowOriginalItemValue(): Orange County
Original after SetRowOriginalItemValue(): Northeast
|
|
|
|
|
Apply DataTable.Rows[0].AcceptChanges()
|
|
|
|
|
I am reposting this message in the .Net Framework discussion board.
The purpose of this email to hopefully gain some insight into implementing a javascript scripting engine within an application framework for a .Net application. I am trying to figure out how to provide scripting capabilities to an application. I would like to provide a scripting engine that enables customers to implement their own business rules. I would like to run custom javascript scripts that handle certain events (OnBeforeUpdate or OnBeforeDelete or OnBeforeAdd, OnAfterAdd, etc...) on different business objects.
I would like to stick with javascript because it's a widely used scripting language. I am just not sure how to go about implementing a javascripting engine into my .Net application framework.
I took a look at Visual Studio for Applications (VSA) which seemed like a possible option but the fact that it's being discontinued has lead to me seek out other options. Again, I would like to stick with a javascript solution.
Any ideas on how to get started with this?
Any thoughts or guidance on this topic would be greatly appreciated. TIA!
Regards,
-Derek
|
|
|
|
|
The first thing I would do if I were you is take a look at the Microsoft.JScript.JScriptCodeProvider[^]. You can use CodeDom to create a type and entry point, and then fill in the statements using a CodeSnippet* object. Then you just have to get familiar with AppDomains and such.
|
|
|
|
|
Hi
I am new to VB.NET. I want to call a batch file that registers Office XP Primary Interop Assemblies. I want to call this file when user clicks some button. On button event what code I need to write If the file name is "register.bat". I have tried it with Shell("register,bat"), it runs windows command prompt but it doesnt recognize the commands written in batch file. Can anyone help me.
Regards
Asif Hameed
|
|
|
|
|
Try this:-
System.Diagnostics.Process.Start("YourFile.bat")
Would you like to see my bits... (and bytes)
|
|
|
|
|
Thanx for your help but it also opens windows command prompt. But as i have told u earlier that i want Visual Studio Command Prompt as it can recognize gacutil command that can register dll files.
|
|
|
|
|
ah sorry, i misunderstood.
You don't need to have VS command prompt open to run GACUtil, you can do it in a normal command window provided you are in the correct directory or use the gacutil.exe's fully qualified location:-
i.e. C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Bin
I'm presuming you are trying to run this from within the batch file so make sure you either CD to the appropriate directory or include the gacutils location in the call.
There may be a slicker way around this but I bet this is simpler!
'================================='
Would you like to see my bits... (and bytes)?
'================================='
|
|
|
|
|
Hi friends,
i got probelm while adding fields to the dataset of report.i will explain bellow
i have a stored procedure. I added a dataset to the report and assigned the stored procedure to the dataset. then i want to another caleculated field to that dataset manually by the report.
i did that but for that field the expretion has a "SUM" function.
like sum(datasetfield1+datasetfield2). it is giving internall error
it is urgent.
it is urgent.
it is urgent.
(
Kiran Kumar
|
|
|
|
|
How toenter a field which is will take the a sum function
ex:
iff(Sum (fields!loan_amt_usd.value) <> 0,(Sum (fields!loan_amt_usd.value, {fields!gr4.value) * 100),0)
while inserting this it is giving internal error and it is closing the application.
Kiran Kumar
|
|
|
|
|
Friends,
Suppose there is an executable developed in C# using VS 2003, and is as such dependent on Version 1.1 of .NET framework.
Will this executable runs on a machine where only .NET framework 2.0 is installed ?
Imtiaz
|
|
|
|
|
Imtiaz Murtaza wrote: Will this executable runs on a machine where only .NET framework 2.0 is installed ?
Yes There might be some small issues, but all in all it should run and work correctly.
|
|
|
|
|
I've an executable that was developed on .NET 1.1
Now i am running it on a machine where both .NET 1.1 and .NET 2.0 are installed. Now in this case which assemblies are loaded, 1.1 on which application is originally dependent or 1.2 ?
Imtiaz
|
|
|
|
|
If it was compiled for .NET 1.1 it will use .NET 1.1 if both runtimes is installed.
|
|
|
|
|
Hi,
I am developing an AddIn which is handling Cut,Copy,Paste commands of IDE(VS.Net 2003).
Although AddIn works fine but if I keep on pressing Ctrl +v it silently dissociates itself from IDE and IDE starts handling all trapped commands.
As per my understanding when cursor crosses a particular limit while pasting data and after that if there is a new Ctrl + V, AddIn stops without calling OnDiscoonection().
Kindly help me .
Ruhina
|
|
|
|
|
Hi all,
I'm using a WebControl object in a .NET Compact Framework application dealing with a big amount of data (map database, images etc...).
I'm trying to play flash videos in the WebControl, however, in some cases,
when the swf file is more than 2 Mo, the video won't play and I get
just a blank widget.
I was first thinking that my PDA was out of resources, but I'm able to
launch Internet Explorer with the same video without any problem while
my app is running.
When I reduce the amount of resources used by my application the videos
is playing well. So it seems to be a memory allocation problem.
Is there any way to increase the amount of memory allocated to the
WebBrowser control ?
I'm coding in C# using CF 2.
Thanks in advance for your help,
Julien
|
|
|
|
|
Hi all,
i am trying to communicate with a virtual com port to get the input from a scanner(a USB device) using the system.io.ports class. i have opened the port (port.open), but when i try to scan some input, the program (using vb.net) won't trigger the DataReceived events, any idea how to get the input from the scanner? Thanks in advance!
elcheah
|
|
|
|
|
USB devices do not work that way. For a scanner, you should be using TWAIN or some other appropriate interface.
--
I've killed again, haven't I?
|
|
|
|
|
Thanks for your reply,
i have stucked there for a very ong time ,i have searched for TWAIN like you have suggested to me, but i am still lost, how to use TWAIN in vb.net? can you give me some guidelines or any tutorial site i can refer to? Thanks
|
|
|
|
|
There are articles about using TWAIN. Here's one now.[^]
--
I've killed again, haven't I?
|
|
|
|
|
Thanks for that article,
Is TWAIN for just image scanning? what about a bar code USB scanner? is that the same?
|
|
|
|
|
Yes, TWAIN is for image acquisition from imaging devices like scanners and digital cameras.
A bar code scanner, on the other hand, is not an imaging device. They could require one of many interfaces. Most USB bar code scanners emulate keyboard input. A simple way to test this, if the bar code scanner is set up, is to open Notepad, focus in the text area, and scan a bar code--like off a box of food or a book.
If, by "scanner" earlier, you meant a bar code scanner, and it supports a virtual COM port, then you can, in fact, use the SerialPort class to connect to that virtual COM port and translate that data as needed. I used SoftCom32 when I first started with a serial (RS232) bar code scanner; it's a tray app that does exactly that--monitors the COM port for data, then emulates keystrokes. I've since replaced it with a sloppy little number I wrote in C# to interface directly to my app, so I don't get stray scans.
--
I've killed again, haven't I?
|
|
|
|
|
I have tried to use the SerialPort class to connect the barcode scanner's virtual COM port, i can detect the scanner's COM port but i failed to read the input in my program. When i try to scan the DataReceived event is not triggered but i can read the input into the HyperTerminal in windows, Any idea how to do read the input of the barcode scanner in vb.net using that class? or is there any alternatives besides that? Thanks
|
|
|
|
|
I don't see any reason why VB wouldn't let you scan bar codes if C# will.
You can post your port opening code so we can take a look at it.
There are a couple simple things to check:
- Make sure your
ReceivedBytesThreshold isn't set to some ungodly high number (should default to 1) - Make sure you call
Open() after you create the port
If it will help, I can post my C# class code this evening when I get back to that computer, so you can see the way I did it. I took a threaded byte-at-a-time approach because the DataReceived events I got resulted in fragmented scans (e.g. scanning "1234567890" got broken up into two events, "123456" and "7890") and I was scanning variable-length bar codes, so I couldn't just set it to fire DataReceived after n bytes.
--
I've killed again, haven't I?
|
|
|
|
|
This is how I open a com port
<br />
With serialPort<br />
.ReceivedBytesThreshold = 1<br />
.PortName = "COM3"<br />
.BaudRate = 9600<br />
.Parity = IO.Ports.Parity.None<br />
.DataBits = 8<br />
.StopBits = IO.Ports.StopBits.One<br />
End With<br />
serialPort.Open()<br />
and detect my com port using
For i As Integer = 0 To My.Computer.Ports.SerialPortNames.Count - 1<br />
combobox.Items.Add(My.Computer.Ports.SerialPortNames(i)) <br />
Next
after i open the COM port, i try to scan in some input won't trigger DataReceived events, anything that i have done wrongly? or anything i should set?
|
|
|
|