Search Results

Search found 676 results on 28 pages for 'dt'.

Page 16/28 | < Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >

  • How do you convert date taken from a bash script to milliseconds in java program?

    - by Matt Pascoe
    I am writing a piece of code in java that needs to take a time sent from a bash script and parse the time to milliseconds. When I check the millisecond conversion on the date everything is correct except for the month I have sent which is January instead of March. Here is the variable I create in the bash script, which later in the script I pass to the java program: TIME=`date +%m%d%Y_%H:%M:%S` Here is the java code which parses the time to milliseconds: String dt = "${scriptstart}"; java.text.SimpleDateFormat scriptStart = new java.text.SimpleDateFormat("MMDDyyyy_HH:mm:ss"); long start = scriptStart.parse(dt).getTime(); The goal of this statement is to find the elapsed time between the start of the script and the current system time. To troubleshoot this I printed out the two: System Time = 1269898069496 (converted = Mon Mar 29 2010 16:27:49 GMT-0500 (Central Daylight Time)) Script Start = 03292010_16:27:45 Script Start in Milli = 1264804065000 (Converted = Fri Jan 29 2010 16:27:45 GMT-0600 (Central Standard Time))

    Read the article

  • Access is re-writing - and breaking - my query!

    - by FrustratedWithFormsDesigner
    I have a query in MS Access (2003) that makes use of a subquery. The subquery part looks like this: ...FROM (SELECT id, dt, details FROM all_recs WHERE def_cd="ABC-00123") AS q1,... And when I switch to Table View to verify the results, all is OK. Then, I wanted the result of this query to be printed on the page header for a report (the query returns a single row that is page-header stuff). I get an error because the query is suddenly re-written as: ...FROM [SELECT id, dt, details FROM all_recs WHERE def_cd="ABC-00123"; ] AS q1,... So it's Ok that the round brackets are automatically replaced by square brackets, Access feels it needs to do that, fine! But why is it adding the ; into the subquery, which causes it to fail? I suppose I could just create new query objects for these subqueries, but it seems a little silly that I should have to do that.

    Read the article

  • How to eliminate one of my extra DropDownLists in ASP.NET?

    - by salvationishere
    I'm developing a C#/SQL web app in VS 2008 but for some reason I have one extra DropDownList. The very first dropdownlist displaying is empty. Can you help me identify the cause of this behavior? I'm baffled! An excerpt of my code is below. private DropDownList[] newcol; // Add DropDownList Control to Placeholder private DropDownList[] CreateDropDownLists() { DropDownList[] dropDowns = new DropDownList[NumberOfControls]; for (int counter = 0; counter < NumberOfControls; counter++) { DropDownList ddl = new DropDownList(); SqlDataReader dr2 = ADONET_methods.DisplayTableColumns(targettable); ddl.ID = "DropDownListID" + counter.ToString(); int NumControls = targettable.Length; DataTable dt = new DataTable(); dt.Load(dr2); ddl.DataValueField = "COLUMN_NAME"; ddl.DataTextField = "COLUMN_NAME"; ddl.DataSource = dt; ddl.SelectedIndexChanged += new EventHandler(ddlList_SelectedIndexChanged); ddl.DataBind(); ddl.AutoPostBack = true; ddl.EnableViewState = true; //Preserves View State info on Postbacks //ddlList.Style["position"] = "absolute"; //ddl.Style["top"] = 80 + "px"; //ddl.Style["left"] = 0 + "px"; dr2.Close(); dropDowns[counter] = ddl; } return dropDowns; } protected void ddlList_SelectedIndexChanged(object sender, EventArgs e) { DropDownList ddl = (DropDownList)sender; string ID = ddl.ID; } //Create display panel private void CreateDisplayPanel() { btnSubmit.Style.Add("top", "auto"); btnSubmit.Style.Add("left", "auto"); btnSubmit.Style.Add("position", "absolute"); newcol = CreateDropDownLists(); for (int counter = 0; counter < NumberOfControls; counter++) { pnlDisplayData.Controls.Add(newcol[counter]); pnlDisplayData.Controls.Add(new LiteralControl("<br><br><br>")); pnlDisplayData.Visible = true; pnlDisplayData.FindControl(newcol[counter].ID); } }

    Read the article

  • Can I use Linq to project a new typed datarow?

    - by itchi
    I currently have a csv file that I'm parsing with an example from here: http://alexreg.wordpress.com/2009/05/03/strongly-typed-csv-reader-in-c/ I then want to loop the records and insert them using a typed dataset xsd to an Oracle database. It's not that difficult, something like: foreach (var csvItem in csvfile) { DataSet.MYTABLEDataTable DT = new DataSet.MYTABLEDataTable(); DataSet.MYTABLERow row = DT.NewMYTABLERow(); row.FIELD1 = csvItem.FIELD1; row.FIELD2 = csvItem.FIELD2; } I was wondering how I would do something with LINQ projection: var test = from csvItem in csvfile select new MYTABLERow { FIELD1 = csvItem.FIELD1, FIELD2 = csvItem.FIELD2 } But I don't think I can create datarows like this without the use of a rowbuilder, or maybe a better constructor for the datarow?

    Read the article

  • How to insert complex strings into Actionscript?

    - by Ole Jak
    How to insert complex strings into Actionscript? So I have a string -vvv -I rc w:// v dv s="60x40" --ut="#scode{vcode=FV1,acode=p3,ab=128,ch=2,rate=4400}:dup{dt=st{ac=http{mime=v/x-flv},mux=mpeg{v},dt=:80/sm.fv}}" How to insert it into code like public var SuperPuperComplexString:String = new String(); SuperPuperComplexString = TO_THAT_COMPLEX_STRING; That string has so many problems like some cart of it can happen to be like regexp BUTI DO NOT want it to be parsed as any kind of reg exp - I need It AS IT IS!) How to put that strange string into variable (put it not inputing it thru UI - hardcode it into AS code)?

    Read the article

  • Oracle: TABLE ACCESS FULL with Primary key?

    - by tim
    There is a table: CREATE TABLE temp ( IDR decimal(9) NOT NULL, IDS decimal(9) NOT NULL, DT date NOT NULL, VAL decimal(10) NOT NULL, AFFID decimal(9), CONSTRAINT PKtemp PRIMARY KEY (IDR,IDS,DT) ) ; SQL>explain plan for select * from temp; Explained. SQL> select plan_table_output from table(dbms_xplan.display('plan_table',null,'serial')); PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------- --------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| --------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 61 | 2 (0)| | 1 | TABLE ACCESS FULL| TEMP | 1 | 61 | 2 (0)| --------------------------------------------------------------- Note ----- - 'PLAN_TABLE' is old version 11 rows selected. SQL server 2008 shows in the same situation Clustered index scan. What is the reason?

    Read the article

  • How should I store Dynamically Changing Data into Server Cache?

    - by Scott
    Hey all, EDIT: Purpose of this Website: Its called Utopiapimp.com. It is a third party utility for a game called utopia-game.com. The site currently has over 12k users to it an I run the site. The game is fully text based and will always remain that. Users copy and paste full pages of text from the game and paste the copied information into my site. I run a series of regular expressions against the pasted data and break it down. I then insert anywhere from 5 values to over 30 values into the DB based on that one paste. I then take those values and run queries against them to display the information back in a VERY simple and easy to understand way. The game is team based and each team has 25 users to it. So each team is a group and each row is ONE users information. The users can update all 25 rows or just one row at a time. I require storing things into cache because the site is very slow doing over 1,000 queries almost every minute. So here is the deal. Imagine I have an excel spreadsheet with 100 columns and 5000 rows. Each row has two unique identifiers. One for the row it self and one to group together 25 rows a piece. There are about 10 columns in the row that will almost never change and the other 90 columns will always be changing. We can say some will even change in a matter of seconds depending on how fast the row is updated. Rows can also be added and deleted from the group, but not from the database. The rows are taken from about 4 queries from the database to show the most recent and updated data from the database. So every time something in the database is updated, I would also like the row to be updated. If a row or a group has not been updated in 12 or so hours, it will be taken out of Cache. Once the user calls the group again via the DB queries. They will be placed into Cache. The above is what I would like. That is the wish. In Reality, I still have all the rows, but the way I store them in Cache is currently broken. I store each row in a class and the class is stored in the Server Cache via a HUGE list. When I go to update/Delete/Insert items in the list or rows, most the time it works, but sometimes it throws errors because the cache has changed. I want to be able to lock down the cache like the database throws a lock on a row more or less. I have DateTime stamps to remove things after 12 hours, but this almost always breaks because other users are updating the same 25 rows in the group or just the cache has changed. This is an example of how I add items to Cache, this one shows I only pull the 10 or so columns that very rarely change. This example all removes rows not updated after 12 hours: DateTime dt = DateTime.UtcNow; if (HttpContext.Current.Cache["GetRows"] != null) { List<RowIdentifiers> pis = (List<RowIdentifiers>)HttpContext.Current.Cache["GetRows"]; var ch = (from xx in pis where xx.groupID == groupID where xx.rowID== rowID select xx).ToList(); if (ch.Count() == 0) { var ck = GetInGroupNotCached(rowID, groupID, dt); //Pulling the group from the DB for (int i = 0; i < ck.Count(); i++) pis.Add(ck[i]); pis.RemoveAll((x) => x.updateDateTime < dt.AddHours(-12)); HttpContext.Current.Cache["GetRows"] = pis; return ck; } else return ch; } else { var pis = GetInGroupNotCached(rowID, groupID, dt);//Pulling the group from the DB HttpContext.Current.Cache["GetRows"] = pis; return pis; } On the last point, I remove items from the cache, so the cache doesn't actually get huge. To re-post the question, Whats a better way of doing this? Maybe and how to put locks on the cache? Can I get better than this? I just want it to stop breaking when removing or adding rows.

    Read the article

  • how to convert the html tags and get a message in string

    - by Ranjana
    how to convert the html tags to the msg bodg in mail function. i.e i have   Company Name: BPL   Industry Type:   i have got the string as datatable dt=new datatable(); string msg= dt.rows[i]["Message"].tostring(); i need to convert this html tags to the exact message; if (boolcheck) { msg.Body = ????????? wat to use over here.... how to remove the html tags and get the exact message } pls help??????????/

    Read the article

  • Filter condition not working properly on list (C#3.0)

    - by Newbie
    I have a datatable that has many NULL or " " strings. Next I am type casting the DataTable to a list . Now if I want to filter those conditions on this list and get the resultant value(without NULL or String.Empty or " " records) what should I do? My code DataTableExtensions.AsEnumerable(dt).ToList().ForEach(i => { if (i[0] != null) { if ((i[0].ToString() != string.Empty)|| (i[0].ToString() != " ")) { list = dt.AsEnumerable().ToList(); } } }); But I am getting all the records. It is not getting filtered. Using C#3.0 Please help Thanks

    Read the article

  • check compiler with break point

    - by KareemSaad
    When I tried to focus on compiler in code i made break point on code if (!IsPostBack) { using (SqlConnection Con = Connection.GetConnection()) { if (Request.QueryString["Category_Id"] != null && DDlProductFamily.SelectedIndex < 0) { SqlCommand Com = new SqlCommand("SelectAllCtageories_Front", Con); Com.CommandType = CommandType.StoredProcedure; Com.Parameters.Add(Parameter.NewInt("@Category_Id", Request.QueryString["Category_Id"])); SqlDataAdapter DA = new SqlDataAdapter(Com); DA.Fill(dt); DataList1.DataSource = dt; DataList1.DataBind(); } but I cannot check condition although I had the value of query string List item

    Read the article

  • how to add a variables which comes from dataset in for loop Collection array in c#?

    - by leventkalay1986
    I have a collection of RSS items protected Collection<Rss.Items> list = new Collection<Rss.Items>(); The class RSS.Items includes properties such as Link, Text, Description, etc. But when I try to read the XML and set these properties: for (int i = 0; i < dt.Rows.Count; i++) { row = dt.Rows[i]; list[i].Link.Equals(row[0].ToString()); list[i].Description.Equals( row[1].ToString()); list[i].Title.Equals( row[2].ToString()); list[i].Date.Equals( Convert.ToDateTime(row[3])); } I get a null reference exception on the line list[i].Link.Equals(row[0].ToString()); What am I doing wrong?

    Read the article

  • How to pass int value to a ajax enabled wcf service method?

    - by Pandiya Chendur
    I am calling an ajax enabled wcf service method from my aspx page... <script type="text/javascript"> function GetEmployee() { Service.GetEmployeeData('1','5',onGetDataSuccess); } function onGetDataSuccess(result) { Iteratejsondata(result) } </script> and my method doesn't seem to get the value [OperationContract] public string GetEmployeeData(int currentPage,int pageSize) { DataSet dt = GetEmployeeViewData(currentPage,pageSize); return GetJSONString(dt.Tables[0]); } when i used a break point to see what is happening in my method currentPage has a value0x00000001 and pageSize has 0x00000005 Any suggestion what am i doing wrong....

    Read the article

  • LINQ. Grouping by days. How to do this easily?

    - by punkouter
    I can't seem to find any god reference on this. I have alot of data in SQL with dates. So I wanted to make a line chart to show this data over time. If I want to show it over a perioud of days then I need to group by days.. But the LOGDATE is the full date.. not the DAY.. So I have this below.. but LINQ doesnt know what 'DayOfYear' property is.. HELP var q = from x in dc.ApplicationLogs let dt = x.LogDate group x by new { dayofyear = dt.Value.DayOfYear } into g select new { iCount = g.Count(), strDate = g.Key };

    Read the article

  • jQuery reference to (this) does not work?

    - by FFish
    I have this href link with text either "attivo" or "non attivo" User can set the item to 'active' or 'closed' in the database with an ajax request $.post() I have 2 questions for these: I can't get the reference to $(this) to work.. I tried it with a normal link and it works, but not wrapped in if/else?? How can I prevent the user from clicking more than one time on the link and submitting several request? Is this a valid concern? Do I need some sort of a small timer or something? First I was thinking about a javascript confirm message, but that's pretty annoying for this function.. HTML: <dl id='album-list'> <dt id="dt-2">some title</dt> <dd id="dd-2"> some description<br /> <div class='links-right'>status: <a class='toggle-active' href='#'>non attivo</a></div> </dd> </dl> <a class="test" href="#">test</a> JS: $('dd a.toggle-active').click(function() { var a_ref = $(this); var id = a_ref.parent().parent().attr('id').substring(3); if (a_ref.text() == "non attivo") { var new_active = "active"; // for db in english $.post("ajax-aa.php", {album_id:id, album_active:new_active}, function(data) { // alert("success"); a_ref.text("non attivo"); // change href text }); } else { var new_active = "closed"; // for db in english $.post("ajax-aa.php", {album_id:id, album_active:new_active}, function(data) { // alert("success"); a_ref.text("attivo"); // change href text }); } return false; }); $('a.test').click(function() { var a_ref = $(this); $.post("ajax-aa.php", {album_id:2, album_active:"active"}, function(data) { a_ref.text("changed"); }); return false; })

    Read the article

  • HTML5 drag & drop: The dragged element content is missing in Webkit browsers.

    - by Cibernox
    I'm trying to implement something similar to a cart where you can drop items from a list. This items (<li> elements) has some elements inside (divs, span, and that stuff). The drag and drop itself works great. But the dragged element's image doesn't show its content in Webkit browsers. My list element has a border an a background color. In Firefox, the image is the whole item. In Webkit browsers, only the dragged element without content. I see the background and border, but without text inside. I tried to make a copy of the element and force it to be the image, but doesn't work. var dt = ev.originalEvent.dataTransfer; dt.setDragImage( $(ev.target).clone()[0], 0, 0); I have a simplified example that exhibit the same behavior: http://jsfiddle.net/ksnJf/1/

    Read the article

  • Pass a datatable model to controller action in MVC

    - by user2906420
    Code: @model System.Data.DataTable <button type="submit" class="btn btn-primary" data-dismiss="modal" aria-hidden="true"> Download</button> [HttpPost] public void getCSV(DataTable dt) { MemoryStream stream = Export.GetCSV(dt); var filename = "ExampleCSV.csv"; var contenttype = "text/csv"; Response.Clear(); Response.ContentType = contenttype; Response.AddHeader("content-disposition", "attachment;filename=" + filename); Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.BinaryWrite(stream.ToArray()); Response.End(); } I want to allow the user to export a CSV file when the button is clicked on. the datatable should be passed to the method getCSV. Please can someone help me. thanks I do not mind using Tempdata to store the datatable and then access it in the controller

    Read the article

  • .NET Garbage Collection behavior (with DataTable)

    - by gmac
    I am wonder why after creating a very simple DataTable and then setting it to null why Garbage Collection does not clear out all the memory used by that DataTable. Here is an example. The variable Before should be equal to Removed but it is not. { long Before = 0, After = 0, Removed = 0, Collected = 0; Before = GC.GetTotalMemory(true); DataTable dt = GetSomeDataTableFromSql(); After = GC.GetTotalMemory(true); dt = null; Removed = GC.GetTotalMemory(true); GC.Collect(); Collected = GC.GetTotalMemory(true); } Gives the following results. Before = 388116 After = 731248 Removed = 530176 Collected = 530176

    Read the article

  • Why is syslog so much slower than file IO?

    - by ceving
    I wrote a simple test program to measure the performance of the syslog function. This are the results of my test system: (Debian 6.0.2 with Linux 2.6.32-5-amd64) Test Case Calls Payload Duration Thoughput [] [MB] [s] [MB/s] -------------------- ---------- ---------- ---------- ---------- syslog 200000 10.00 7.81 1.28 syslog %s 200000 10.00 9.94 1.01 write /dev/null 200000 10.00 0.03 343.93 printf %s 200000 10.00 0.13 76.29 The test program did 200000 system calls writing 50 Bytes of data during each call. Why is Syslog more than ten times slower than file IO? This is the program I used to perform the test: #include <fcntl.h> #include <stdio.h> #include <string.h> #include <sys/stat.h> #include <sys/time.h> #include <sys/types.h> #include <syslog.h> #include <unistd.h> const int iter = 200000; const char msg[] = "123456789 123456789 123456789 123456789 123456789"; struct timeval t0; struct timeval t1; void start () { gettimeofday (&t0, (void*)0); } void stop () { gettimeofday (&t1, (void*)0); } void report (char *action) { double dt = (double)t1.tv_sec - (double)t0.tv_sec + 1e-6 * ((double)t1.tv_usec - (double)t0.tv_usec); double mb = 1e-6 * sizeof (msg) * iter; if (action == NULL) printf ("Test Case Calls Payload Duration Thoughput \n" " [] [MB] [s] [MB/s] \n" "-------------------- ---------- ---------- ---------- ----------\n"); else { if (strlen (action) > 20) action[20] = 0; printf ("%-20s %-10d %-10.2f %-10.2f %-10.2f\n", action, iter, mb, dt, mb / dt); } } void test_syslog () { int i; openlog ("test_syslog", LOG_PID | LOG_NDELAY, LOG_LOCAL0); start (); for (i = 0; i < iter; i++) syslog (LOG_DEBUG, msg); stop (); closelog (); report ("syslog"); } void test_syslog_format () { int i; openlog ("test_syslog", LOG_PID | LOG_NDELAY, LOG_LOCAL0); start (); for (i = 0; i < iter; i++) syslog (LOG_DEBUG, "%s", msg); stop (); closelog (); report ("syslog %s"); } void test_write_devnull () { int i, fd; fd = open ("/dev/null", O_WRONLY); start (); for (i = 0; i < iter; i++) write (fd, msg, sizeof(msg)); stop (); close (fd); report ("write /dev/null"); } void test_printf () { int i; FILE *fp; fp = fopen ("/tmp/test_printf", "w"); start (); for (i = 0; i < iter; i++) fprintf (fp, "%s", msg); stop (); fclose (fp); report ("printf %s"); } int main (int argc, char **argv) { report (NULL); test_syslog (); test_syslog_format (); test_write_devnull (); test_printf (); }

    Read the article

  • How to reset darktable

    - by AKAGoodGravy
    I need a way of reseting darktable to its factory settings. With shotwell it is simply a case of deleting the home directory for shotwell, but there doesn't appear to be one for DT under it's name. I can't use darktable for more than about 30 seconds as it attempts to load up the library of about 30,000 RAW files from one folder and unsurprisingly crashes. This is the only thing holding me back from 100% cross over to ubuntu.

    Read the article

  • Physics Engine [Collision Response, 2-dimensional] experts, help!! My stack is unstable!

    - by Register Sole
    Previously, I struggle with the sequential impulse-based method I developed. Thanks to jedediah referring me to this paper, I managed to rebuild the codes and implement the simultaneous impulse based method with Projected-Gauss-Seidel (PGS) iterative solver as described by Erin Catto (mentioned in the reference of the paper as [Catt05]). So here's how it currently is: The simulation handles 2-dimensional rotating convex polygons. Detection is using separating-axis test, with a SKIN, meaning closest points between two polygons is detected and determined if their distance is less than SKIN. To resolve collision, simultaneous impulse-based method is used. It is solved using iterative solver (PGS-solver) as in Erin Catto's paper. Error-correction is implemented using Baumgarte's stabilization (you can refer to either paper for this) using J V = beta/dt*overlap, J is the Jacobian for the constraints, V the matrix containing the velocities of the bodies, beta an error-correction parameter that is better be < 1, dt the time-step taken by the engine, and overlap, the overlap between the bodies (true overlap, so SKIN is ignored). However, it is still less stable than I expected :s I tried to stack hexagons (or squares, doesn't really matter), and even with only 4 to 5 of them, they hardly stand still! Also note that I am not looking for a sleeping scheme. But I would settle if you have any explicit scheme to handle resting contacts. That said, I would be more than happy if you have a way of treating it generally (as continuous collision, instead of explicitly as a special state). Ideas I have: I would try adding a damping term (proportional to velocity) to the Baumgarte. Is this a good idea in general? If not I would not want to waste my time trying to tune the parameter hoping it magically works. Ideas I have tried: Using simultaneous position based error correction as described in the paper in section 5.3.2, turned out to be worse than the current scheme. If you want to know the parameters I used: Hexagons, side 50 (pixels) gravity 2400 (pixels/sec^2) time-step 1/60 (sec) beta 0.1 restitution 0 to 0.2 coeff. of friction 0.2 PGS iteration 10 initial separation 10 (pixels) mass 1 (unit is irrelevant for now, i modified velocity directly<-impulse method) inertia 1/1000 Thanks in advance! I really appreciate any help from you guys!! :)

    Read the article

  • Windows VirtualBox failed to attach USB device to Linux Guest

    - by joltmode
    I have Windows 7 64bit Host system, and I am using VirtualBox 4.1.18 (r78361). I have an Arch Linux Guest OS. I have installed VirtualBox Extension Pack (to enable USB2 support) and added my USB device filter to VM. I have also installed the Guest Additions provided by Arch: virtualbox-archlinux-additions (but I have no idea whether it's actually needed for my environment). I can see my USB device from VirtualBox Devices menu. Whenever I am trying to access it, I end up with: Failed to attach the USB device Kingston DT 100 G2 [0100] to the virtual machine Archlinux. USB device 'Kingston DT 100 G2' with UUID {a836ec33-0f41-4ca7-a31d-09cceaf5d173} is busy with a previous request. Please try again later. Details ? Result Code:    E_INVALIDARG (0x80070057) Component:      HostUSBDevice Interface:      IHostUSBDevice {173b4b44-d268-4334-a00d-b6521c9a740a} Callee:         IConsole {1968b7d3-e3bf-4ceb-99e0-cb7c913317bb} From what I have googled, most guides shows how to solve this the other way around - Linux Host to Windows Guest. How do I resolve this? Update I have tried to Eject (virtually, not physically) the device from my Windows Host system and then try to access the Device from Guest. Same error.

    Read the article

  • validation in datagrid while insert update in asp.net

    - by abhi
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default7.aspx.cs" Inherits="Default7" % <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" % Untitled Page   <telerik:GridTemplateColumn Visible="false"> <ItemTemplate> <asp:Label ID="lblEmpID" runat="server" Text='<%# bind("pid") %>'> </asp:Label> </ItemTemplate> </telerik:GridTemplateColumn> <telerik:GridBoundColumn UniqueName="Fname" HeaderText="Fname" DataField="Fname" CurrentFilterFunction="NotIsNull" SortExpression="Fname"> </telerik:GridBoundColumn> <telerik:GridBoundColumn UniqueName="Lname" HeaderText="Lname" DataField="Lname" CurrentFilterFunction="NotIsNull" SortExpression="Lname"> </telerik:GridBoundColumn> <telerik:GridBoundColumn UniqueName="Designation" HeaderText="Designation" DataField="Designation" CurrentFilterFunction="NotIsNull" SortExpression="Designation"> </telerik:GridBoundColumn> <telerik:GridEditCommandColumn> </telerik:GridEditCommandColumn> <telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName="column"> </telerik:GridButtonColumn> </Columns> <EditFormSettings> <FormTemplate> <table> <tr> <td>Fname*</td> <td> <asp:HiddenField ID="Fname" runat="server" Visible="false" /> <asp:TextBox ID="txtFname" runat="server" Text='<%#("Fname")%>'> </asp:TextBox> <asp:RequiredFieldValidator ID="EvalFname" ControlToValidate="txtFname" ErrorMessage="Enter Name" runat="server" ValidationGroup="Update"> *</asp:RequiredFieldValidator> </td> </tr> <tr> <td>Lname*</td> <td> <asp:HiddenField ID="HiddenField1" runat="server" Visible="false" /> <asp:TextBox ID="txtLname" runat="server" Text='<%#("Lname")%>'> </asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="txtLname" ErrorMessage="Enter Name" runat="server" ValidationGroup="Update"> *</asp:RequiredFieldValidator> </td> </tr> <tr> <td>Designation* </td> <td> <asp:HiddenField ID="HiddenField2" runat="server" Visible="false" /> <asp:TextBox ID="txtDesignation" runat="server" Text='<%#("Designation")%>'> </asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator2" ControlToValidate="txtDesignation" ErrorMessage="Enter Designation" runat="server" ValidationGroup="Update"> *</asp:RequiredFieldValidator> </td> </tr> </table> </FormTemplate> <EditColumn UpdateText="Update record" UniqueName="EditCommandColumn1" CancelText="Cancel edit"> </EditColumn> </EditFormSettings> </MasterTableView> </telerik:RadGrid> </form> this is my code i want to perform validation using the required validators but i think m missing smthin so pls help, here's my code behind using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.SqlClient; using Telerik.Web.UI; public partial class Default7 : System.Web.UI.Page { string strQry; public SqlDataAdapter da; public DataSet ds; public SqlCommand cmd; public DataTable dt; string strCon = "Data Source=MINETDEVDATA; Initial Catalog=ML_SuppliersProd; User Id=sa; Password=@MinetApps7;"; public SqlConnection con; protected void Page_Load(object sender, EventArgs e) { } protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e) { dt = new DataTable(); con = new SqlConnection(strCon); da = new SqlDataAdapter(); try { strQry = "SELECT * FROM table2"; con.Open(); da.SelectCommand = new SqlCommand(strQry,con); da.Fill(dt); RadGrid1.DataSource = dt; } finally { con.Close(); } } protected void RadGrid1_DeleteCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) { con = new SqlConnection(strCon); cmd = new SqlCommand(); GridDataItem item = (GridDataItem)e.Item; string pid = item.OwnerTableView.DataKeyValues[item.ItemIndex]["pid"].ToString(); con.Open(); string delete = "DELETE from table2 where pid='"+pid+"'"; cmd.CommandText = delete; cmd.Connection = con; cmd.ExecuteNonQuery(); con.Close(); } protected void RadGrid1_UpdateCommand(object source, GridCommandEventArgs e) { GridEditableItem radgriditem = e.Item as GridEditableItem; string pid = radgriditem.OwnerTableView.DataKeyValues[radgriditem.ItemIndex]["pid"].ToString(); string firstname = (radgriditem["Fname"].Controls[0] as TextBox).Text; string lastname = (radgriditem["Lname"].Controls[0] as TextBox).Text; string designation = (radgriditem["Designation"].Controls[0] as TextBox).Text; con = new SqlConnection(strCon); cmd = new SqlCommand(); try { con.Open(); string update = "UPDATE table2 set Fname='" + firstname + "',Lname='" + lastname + "',Designation='" + designation + "' WHERE pid='" + pid + "'"; cmd.CommandText = update; cmd.Connection = con; cmd.ExecuteNonQuery(); con.Close(); } catch (Exception ex) { RadGrid1.Controls.Add(new LiteralControl("Unable to update Reason: " + ex.Message)); e.Canceled = true; } } protected void RadGrid1_InsertCommand(object source, GridCommandEventArgs e) { GridEditFormInsertItem insertitem = (GridEditFormInsertItem)e.Item; string firstname = (insertitem["Fname"].Controls[0] as TextBox).Text; string lastname = (insertitem["Lname"].Controls[0] as TextBox).Text; string designation = (insertitem["Designation"].Controls[0] as TextBox).Text; con = new SqlConnection(strCon); cmd = new SqlCommand(); try { con.Open(); String insertQuery = "INSERT into table1(Fname,Lname,Designation) Values ('" + firstname + "','" + lastname + "','" + designation + "')"; cmd.CommandText = insertQuery; cmd.Connection = con; cmd.ExecuteNonQuery(); con.Close(); } catch(Exception ex) { RadGrid1.Controls.Add(new LiteralControl("Unable to insert Reason:" + ex.Message)); e.Canceled = true; } } }

    Read the article

  • NullPointerException, Collections not storing data?

    - by Elliott
    Hi there, I posted this question earlier but not with the code in its entirety. The coe below also calls to other classes Background and Hydro which I have included at the bottom. I have a Nullpointerexception at the line indicate by asterisks. Which would suggest to me that the Collections are not storing data properly. Although when I check their size they seem correct. Thanks in advance. PS: If anyone would like to give me advice on how best to format my code to make it readable, it would be appreciated. Elliott package exam0607; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.URL; import java.util.Collection; import java.util.Scanner; import java.util.Vector; import exam0607.Hydro; import exam0607.Background;// this may not be necessary???? FIND OUT public class HydroAnalysis { public static void main(String[] args) { Collection hydroList = null; Collection backList = null; try{hydroList = readHydro("http://www.hep.ucl.ac.uk/undergrad/3459/exam_data/2006-07/final/hd_data.dat");} catch (IOException e){ e.getMessage();} try{backList = readBackground("http://www.hep.ucl.ac.uk/undergrad/3459/exam_data/2006-07/final/hd_bgd.dat"); //System.out.println(backList.size()); } catch (IOException e){ e.getMessage();} for(int i =0; i <=14; i++ ){ String nameroot = "HJK"; String middle = Integer.toString(i); String hydroName = nameroot + middle + "X"; System.out.println(hydroName); ALGO_1(hydroName, backList, hydroList); } } public static Collection readHydro(String url) throws IOException { URL u = new URL(url); InputStream is = u.openStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader b = new BufferedReader(isr); String line =""; Collection data = new Vector(); while((line = b.readLine())!= null){ Scanner s = new Scanner(line); String name = s.next(); System.out.println(name); double starttime = Double.parseDouble(s.next()); System.out.println(+starttime); double increment = Double.parseDouble(s.next()); System.out.println(+increment); double p = 0; double nterms = 0; while(s.hasNextDouble()){ p = Double.parseDouble(s.next()); System.out.println(+p); nterms++; System.out.println(+nterms); } Hydro SAMP = new Hydro(name, starttime, increment, p); data.add(SAMP); } return data; } public static Collection readBackground(String url) throws IOException { URL u = new URL(url); InputStream is = u.openStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader b = new BufferedReader(isr); String line =""; Vector data = new Vector(); while((line = b.readLine())!= null){ Scanner s = new Scanner(line); String name = s.next(); //System.out.println(name); double starttime = Double.parseDouble(s.next()); //System.out.println(starttime); double increment = Double.parseDouble(s.next()); //System.out.println(increment); double sum = 0; double p = 0; double nterms = 0; while((s.hasNextDouble())){ p = Double.parseDouble(s.next()); //System.out.println(p); nterms++; sum += p; } double pbmean = sum/nterms; Background SAMP = new Background(name, starttime, increment, pbmean); //System.out.println(SAMP); data.add(SAMP); } return data; } public static void ALGO_1(String hydroName, Collection backgs, Collection hydros){ //double aMin = Double.POSITIVE_INFINITY; //double sum = 0; double intensity = 0; double numberPN_SIG = 0; double POSITIVE_PN_SIG =0; //int numberOfRays = 0; for(Hydro hd: hydros){ System.out.println(hd.H_NAME); for(Background back : backgs){ System.out.println(back.H_NAME); if(back.H_NAME.equals(hydroName)){//ERROR HERE double PN_SIG = Math.max(0.0, hd.PN - back.PBMEAN); numberPN_SIG ++; if(PN_SIG 0){ intensity += PN_SIG; POSITIVE_PN_SIG ++; } } } double positive_fraction = POSITIVE_PN_SIG/numberPN_SIG; if(positive_fraction < 0.5){ System.out.println( hydroName + "is faulty" ); } else{System.out.println(hydroName + "is not faulty");} System.out.println(hydroName + "has instensity" + intensity); } } } THE BACKGROUND CLASS package exam0607; public class Background { String H_NAME; double T_START; double DT; double PBMEAN; public Background(String name, double starttime, double increment, double pbmean) { name = H_NAME; starttime = T_START; increment = DT; pbmean = PBMEAN; }} AND THE HYDRO CLASS public class Hydro { String H_NAME; double T_START; double DT; double PN; public double n; public Hydro(String name, double starttime, double increment, double p) { name = H_NAME; starttime = T_START; increment = DT; p = PN; } }

    Read the article

  • Custom event loop and UIKit controls. What extra magic Apple's event loop does?

    - by tequilatango
    Does anyone know or have good links that explain what iPhone's event loop does under the hood? We are using a custom event loop in our OpenGL-based iPhone game framework. It calls our game rendering system, calls presentRenderbuffer and pumps events using CFRunLoopRunInMode. See the code below for details. It works well when we are not using UIKit controls (as a proof, try Facetap, our first released game). However, when using UIKit controls, everything almost works, but not quite. Specifically, scrolling of UIKit controls doesn't work properly. For example, let's consider following scenario. We show UIImagePickerController on top of our own view. UIImagePickerController covers our custom view We also pause our own rendering, but keep on using the custom event loop. As said, everything works, except scrolling. Picking photos works. Drilling down to photo albums works and transition animations are smooth. When trying to scroll photo album view, the view follows your finger. Problem: when scrolling, scrolling stops immediately after you lift your finger. Normally, it continues smoothly based on the speed of your movement, but not when we are using the custom event loop. It seems that iPhone's event loop is doing some magic related to UIKit scrolling that we haven't implemented ourselves. Now, we can get UIKit controls to work just fine and dandy together with our own system by using Apple's event loop and calling our own rendering via NSTimer callbacks. However, I'd still like to understand, what is possibly happening inside iPhone's event loop that is not implemented in our custom event loop. - (void)customEventLoop { OBJC_METHOD; float excess = 0.0f; while(isRunning) { animationInterval = 1.0f / openGLapp->ticks_per_second(); // Calculate the target time to be used in this run of loop float wait = max(0.0, animationInterval - excess); Systemtime target = Systemtime::now().after_seconds(wait); Scope("event loop"); NSAutoreleasePool* pool = [[ NSAutoreleasePool alloc] init]; // Call our own render system and present render buffer [self drawView]; // Pump system events [self handleSystemEvents:target]; [pool release]; excess = target.seconds_to_now(); } } - (void)drawView { OBJC_METHOD; // call our own custom rendering bool bind = openGLapp->app_render(); // bind the buffer to be THE renderbuffer and present its contents if (bind) { opengl::bind_renderbuffer(renderbuffer); [context presentRenderbuffer:GL_RENDERBUFFER_OES]; } } - (void) handleSystemEvents:(Systemtime)target { OBJC_METHOD; SInt32 reason = 0; double time_left = target.seconds_since_now(); if (time_left <= 0.0) { while((reason = CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, TRUE)) == kCFRunLoopRunHandledSource) {} } else { float dt = time_left; while((reason = CFRunLoopRunInMode(kCFRunLoopDefaultMode, dt, FALSE)) == kCFRunLoopRunHandledSource) { double time_left = target.seconds_since_now(); if (time_left <= 0.0) break; dt = (float) time_left; } } }

    Read the article

  • [Flex 4 and .Net] Retrieving tables from SQL database

    - by mG
    Hi everyone, As the title says, I want to retrieve tables of data from a SQL database, using Flex 4 and .Net WebService. I'm new to both Flex and DotNet. Please tell me a proper way to do it. This is what I've done so far: Retrieving an array of string: (this works) .Net: [WebMethod] public String[] getTestArray() { String[] arStr = { "AAA", "BBB", "CCC", "DDD" }; return arStr; } Flex 4: <?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"> <fx:Script> <![CDATA[ import mx.collections.ArrayCollection; import mx.controls.Alert; import mx.rpc.events.ResultEvent; [Bindable] private var ac:ArrayCollection = new ArrayCollection(); protected function btn_clickHandler(event:MouseEvent):void { ws.getTestArray(); } protected function ws_resultHandler(event:ResultEvent):void { ac = event.result as ArrayCollection; Alert.show(ac.toString()); } ]]> </fx:Script> <fx:Declarations> <s:WebService id="ws" wsdl="http://localhost:50582/Service1.asmx?WSDL" result="ws_resultHandler(event)"/> </fx:Declarations> <s:Button x="10" y="30" label="Button" id="btn" click="btn_clickHandler(event)"/> </s:Application> Retrieving a DataTable: (this does not work) DotNet: [WebMethod] public DataTable getUsers() { DataTable dt = new DataTable("Users"); SqlConnection conn = new SqlConnection("server = 192.168.1.50; database = MyDatabase; user id = sa; password = 1234; integrated security = false"); SqlDataAdapter da = new SqlDataAdapter("select vFName, vLName, vEmail from Users", conn); da.Fill(dt); return dt; } Flex 4: <?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"> <fx:Script> <![CDATA[ import mx.collections.ArrayCollection; import mx.controls.Alert; import mx.rpc.events.ResultEvent; [Bindable] private var ac:ArrayCollection = new ArrayCollection(); protected function btn_clickHandler(event:MouseEvent):void { ws.getUsers(); } protected function ws_resultHandler(event:ResultEvent):void { ac = event.result as ArrayCollection; Alert.show(ac.toString()); } ]]> </fx:Script> <fx:Declarations> <s:WebService id="ws" wsdl="http://localhost:50582/Service1.asmx?WSDL" result="ws_resultHandler(event)"/> </fx:Declarations> <s:Button x="10" y="30" label="Button" id="btn" click="btn_clickHandler(event)"/> </s:Application>

    Read the article

< Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >