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: Public Function SetRowOriginalItemValue(ByVal primaryKeyColumn As DataColumn, ByVal key As Object, ByVal editColumn As DataColumn, ByVal value As Object) As Boolean 'Utils.Assert.ArgumentCheckForNullReference(primaryKeyColumn, "primaryKeyColumn") 'Utils.Assert.ArgumentCheckForNullReference(key, "key") 'Utils.Assert.ArgumentCheckForNullReference(editColumn, "editColumn") 'Utils.Assert.ArgumentCheckExpectedType(key, primaryKeyColumn.DataType) 'Utils.Assert.ArgumentCheckExpectedType(value, editColumn.DataType) Dim t As DataTable = editColumn.Table Dim d As DataSet = t.DataSet Dim s As New IO.MemoryStream d.WriteXml(s, XmlWriteMode.DiffGram) s.Seek(0, IO.SeekOrigin.Begin) Dim doc As New Xml.XmlDocument doc.Load(s) Dim nsmgr As Xml.XmlNamespaceManager = New Xml.XmlNamespaceManager(doc.NameTable) nsmgr.AddNamespace("diffgr", "urn:schemas-microsoft-com:xml-diffgram-v1") nsmgr.AddNamespace("my", d.Namespace) Dim xp As String = String.Format(New Globalization.CultureInfo("en-US"), _ "/diffgr:diffgram/diffgr:before/my:{0}[starts-with(@diffgr:id, '{0}')]/my:{1}[text()='{2}']/../my:{3}/node()", _ t.TableName, primaryKeyColumn.ColumnName, key, editColumn.ColumnName) Dim n As Xml.XmlNode = doc.DocumentElement.SelectSingleNode(xp, nsmgr) If Not n Is Nothing Then n.Value = value d.Clear() d.ReadXml(New IO.StringReader(doc.InnerXml), XmlReadMode.DiffGram) Return True End If Return False End Function '''''''''''''''''''' Sub SetRowOriginalItemValueTest() Dim d As New DistrictSet Dim row As DistrictSet.DistrictsRow row = d.Districts.NewDistrictsRow row.DistrictId = 109901 row.DistrictName = "Orange County" d.Districts.AddDistrictsRow(row) d.AcceptChanges() d.Districts(0).DistrictName = "West Coast" Diagnostics.Trace.WriteLine("Current: " & d.Districts.Item(0)("DistrictName")) Diagnostics.Trace.WriteLine("Original before SetRowOriginalItemValue(): " & d.Districts.Item(0)("DistrictName", DataRowVersion.Original)) SetRowOriginalItemValue(d.Districts.DistrictIdColumn, 109901, d.Districts.DistrictNameColumn, "Northeast")
NewSilence
Posts
-
Is there a way to change the original value in the DataRow? -
picture inserting.please help me!there is the "image" data type in the ms sql server. you can use it to store your images. cmdUpdate.Parameters.Add(New System.Data.SqlClient.SqlParameter("@ImageID", System.Data.SqlDbType.Int, 4)) cmdUpdate.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Data", System.Data.SqlDbType.VarBinary, 2147483647))
-
Possible to pass table as parametr to stored procedure???I guess yes if will user only one text parameter that contais your table in an xml format then you can user sp_xml_preparedocument and openxml to read rows from your table being passes through SP parameters
-
select statement in sqlserver 2000better use SPs. you code is not secure. I can enter "; delete from table" in the text box and your data are gone
-
select statement in sqlserver 2000I guess the problem is here cishi_us wrote: sqlCmd = new SqlCommand(“select username,password from table where username=@textbox1.text”); sqlDataAdapter da = new SqlDataAdapter(); da= cmd.executeReader() you did not add a paramter to the params collection of the sql command p = new SqlParameter("@Text"); p.Value=TextBox1.Text; cmd.Parameters.Add(p);
-
DataSet.WriteXml Problem With Nested Elements Of Same Nametry to use qualified names.
<root xmlns:s1="blahblah1" xmlns:s2="blahblah2"> <s1:reg> <s2:reg></s2:reg> </s1:reg> </root>
why don't to use XSDs and strong typed datasets?. I think that prevents such errors -
Disabling parent pageyes, it is possible. System.Web.UI.WebControls.WebControl has "Enabled" property and System.Web.UI.HtmlControls.HtmlControl has "Disabled" property and those classes and page class have the child control collection. You can try to do the following: 1. you press a button 2. page reloads. and all controls are disables. 3. parent page opens the child webform using JS code 4. you close the child form and that reloads the parent page 5. parent page is reloaded and all controls are enabled. I guess it the easiest way to implement otherwise you should try to write JS code(I think that should take more time to implement)
-
Long-term web-development: Win/MS or Linux/open srci think you will be able to decide what techs it might best to use basing on deliverables of the 1st stage. ASP.NET and JavaScript are different things. parts of an ASP.NET are content(web forms, html etc), program logic(executable files, scripts that could be JS) and config (iis setting, web config, css). I'd say that an ASP.NET is kind of JSP. but there are several differences e.g. codebehind. it is a division of the web page into two units those ones are view and program logic. so that it makes much easier to change the face of your application. Also ASP.NET has many useful web controls that JSP has not. when you use JSP sometimes you have to write own web control that takes time. JavaScript is a scripting language targeted specifically at the Internet. You can use JS language to interact with DHTML DOM from the web browser side. Yes, Java and C# are from the same league. but they have significant different architectures. Java code is compiled into kind of intermediate language that is interpreted by the java virtual machine. C# code is compiled into MSIL that later is compiled into e.g x86 instructions. so that C# code is much faster than Java.
-
Long-term web-development: Win/MS or Linux/open srcit's to understand the size of the project from your post but I see here two options 1. MS technilogies: they are not cheap and maybe you should buy them. but ms technologies allow you to make extensible scalable things much faster. e.g. you can use 3rd party data access level generators that generate the DB structure, Views, SPs and .net code. VS generates useful code and allows easy to debug the code. MSSQL allow to use more complex data queries. as a rule, support is much cheaper using ms techs. 2. Unix/Linux/MySQL: most of tools are free(PHP,Apache,Perl,MySql etc). PHP and perl are script langs so they are slower than .net ones. I have never seen such powerful PHP IDEs as MS VS. Java IDEs are very powerful now(but I would prefer the .net technology it seems to me that it gets things done faster than Java) but you will have to write more code than when you use .net lang. mysql has many limitations sometimes you have to write many sql sripts to collect a required result when you need to write only one sql queries in T-SQL. I guess you need to take a close look at those techs and at your reqs. but before you have to analyze and define what you want to make. then look at the solution from the technology point of view. I guess that will help you to make right choice between cheap development/support and cheap technologies.
-
View child records in datagridI can suggest you to use the Infragistics NetAdvantage http://www.infragistics.com/products/NetAdvantage/WebForms/Default.aspx[^], otherwise you have to code too much. It has extremely wonderful datagrid. My customers like it I think you will like it too
-
I tried a serialization deserialization network applicationwhat formatter do you use? SOAP, XML, Binary? how do you serialize and deserialize your instance?
-
reporting services sql server 2000http://msdn.microsoft.com/library/en-us/RSPROG/htm/rsp_ref_clr_dataproc_8p85.asp?frame=true[^] check that there is also the data processing ext. sample http://msdn.microsoft.com/library/default.asp?url=/library/en-us/RSAMPLES/htm/rss_sampleapps_v1_8spu.asp[^]
-
Reporting Servicenot sure what you meant sayign "Print-Preview and Layout-Preview". I had the same problems with pages# when tried to render to html. i were googling but no success then I've resolved that by addind the "page n of m". i parse a resulting html content using the regex "page \d+ of \d+". found max(m) and then removed page # from the html
-
rdl querylooks like you can't. read my previous post it seems i've described how to solve that
-
Data Source for Reporting Servicesyou can use SP with parameters as queries in the RDL and your SP may return a record set that depends on parameters you pass to. you can pass those parameters to the msrs report thru ReportingService.Render() webmethod. check the followin http://msdn.microsoft.com/library/default.asp?url=/library/en-us/RSPROG/htm/rsp\_ref\_soapapi\_service\_ak\_1xfd.asp\[^\] http://msdn.microsoft.com/library/default.asp?url=/library/en-us/RSPROG/htm/rsp\_ref\_soapapi\_service\_lz\_49f6.asp\[^\] http://www32.brinkster.com/srisamp/sqlArticles/article\_41.htm\[^\] probaly you work on a huge project that has many many sps and some of them use temporary tables or returns multiple recordset then you are not able to use those sps in the msrs because as a rule those sps does not have a predifined data scheme. may be you applcation has eiter many webservices or data access components that provied data that could be shown in reports then maybe it makes sense to make an extension to the msrs that is tied with your application. so that you can reuse existing code that retrives data from the db. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/RSPROG/htm/rsp\_ref\_clr\_dataproc\_8p85.asp\[^\] it looks like it's easy to make
-
transaction issueyou can pass either idbtransaction or iconnection to your methods that update the db
tran = conn.begintranasction try AddReminderDB(tran) tran.rollback catch ex throw finally tran.commit conn.close end try
-
Asp.net maintaining sessionsWhat DB do you use? MS SQL has function that genterates a unique identifier value. It's NEWID(). You can use it to sort records randomly.
select top 10 * from YourTableName order by newid()
-
Replace Method case insensitiveawu25 wrote: if user enters "This is GrEEn color" I want to replace the word GrEEn with GrEEn. try regular expressions
Dim r As System.Text.RegularExpressions.Regex = New System.Text.RegularExpressions.Regex("red", System.Text.RegularExpressions.RegexOptions.IgnoreCase) Dim s As String = "word1 word2 reD word3" Dim s2 As String = r.Match(s).Value Dim res As String = r.Replace(s, "[font color=" & s2 & "]" & s2 & "[/font]")
-
Chage row color, image on conditions and a default string if emply in Datagridawu25 wrote: If the email has not been read display the row in white and image "A" at beginig of the row else display in light blue and display image "B" Create templete clmn in your DG then add tag and check it run as a server control and add your own ItemDataBound event hander of DG
Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid1.ItemDataBound If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then Dim r As DataRow = CType(e.Item.DataItem, DataRowView).Row Dim img As System.Web.UI.WebControls.Image = e.Item.FindControl("img1") If IsMailRead(r("ID")) Then e.Item.Attributes.Add("style", "background-color:white") img.ImageUrl = "/imgA.gif" Else e.Item.Attributes.Add("style", "background-color:grey") img.ImageUrl = "/imgB.gif" End If
-
creating virtual directory in vc++how do the follow in c++??? dim srvobj dim vdo set srvobj = GetObject("IIS://LocalHost/MSFTPSVC/1/Root") set vdo = srvobj.create("IIsFtpVirtualDir", "mydir") 'set vdo = srvobj.getobject("IIsFtpVirtualDir", "mydir") vdo.setinfo vdo.AccessRead = True vdo.Put "Path", "c:\tmp" vdo.SetInfo thanks and regard!