Daily Archives

Articles indexed Thursday November 15 2012

Page 5/14 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • How do produce a "mucus spreading" effect in a 2D environment?

    - by nathan
    Here is an example of such a mucus spreading. The substance is spread around the source (in this example, the source would be the main alien building). The game is starcraft, the purple substance is called creep. How this kind of substance spreading would be achieved in a top down 2D environment? Recalculating the substance progression and regenerate the effect on the fly each frame or rather use a large collection of tiles or something else?

    Read the article

  • Auto Save and Auto Load Game onto the Device's Storage Concept Question

    - by David Dimalanta
    I'm trying to make a simple app that will test the save and load state. Is it a good idea to make an app that has an auto save and load game feature only every time the newbies open the first app then continues it on the other day? I tried making a sprite that is moving, starting at the center. When I close and re-open the app, the sprite goes back to the center instead of the last coordinate where the sprite land on this part (i.e. at the top). The thing I want to know how the sequence of saving and loading goes like this: I open the app The starting sprite at the center. It displays a coordinate of the sprite plus number of times does the sprite move. I exit the app that automatically saves the game without notice. Finally, when I re-opened it, it automatically loads the game retaining the number of times the sprite move, coordinates, and the sprite's area landed. These steps above are similar, but not the sprite movement test app, to the sequence of saving and loading the game's level and record in Jewel Stackers for the Android app. And, by default, if there is no SD card in any tab or phone that runs on Android, does it automatically save/load onto the internal drive or the APK file itself? Is it also useful to use auto save and auto load feature for protecting and fetching informations (i.e. fastest time, last time where the sprite is located via coordinates, etc.)?

    Read the article

  • Querying the size of a drive on a remote server is giving me an error

    - by Testifier
    Here's what I have: public static bool DriveHasLessThanTenPercentFreeSpace(string server) { long driveSize = 0; long freeSpace = 0; var oConn = new ConnectionOptions {Username = "username", Password = Settings.Default.SQLServerAdminPassword}; var scope = new ManagementScope("\\\\" + server + "\\root\\CIMV2", oConn); //connect to the scope scope.Connect(); //construct the query var query = new ObjectQuery("SELECT FreeSpace FROM Win32_LogicalDisk where DeviceID = 'D:'"); //this class retrieves the collection of objects returned by the query var searcher = new ManagementObjectSearcher(scope, query); //this is similar to using a data adapter to fill a data set - use an instance of the ManagementObjectSearcher to get the collection from the query and store it ManagementObjectCollection queryCollection = searcher.Get(); //iterate through the object collection and get what you're looking for - in my case I want the FreeSpace of the D drive foreach (ManagementObject m in queryCollection) { //the FreeSpace value is in bytes freeSpace = Convert.ToInt64(m["FreeSpace"]); //error happens here! driveSize = Convert.ToInt64(m["Size"]); } long percentFree = ((freeSpace / driveSize) * 100); if (percentFree < 10) { return true; } return false; } This line of code is giving me an error: driveSize = Convert.ToInt64(m["Size"]); The error says: ManagementException was unhandled by user code Not found I'm assuming the query to get the drive size is wrong. Please note that I AM getting the freeSpace value at the line: freeSpace = Convert.ToInt64(m["FreeSpace"]); So I know the query IS working for freeSpace. Can anyone give me a hand?

    Read the article

  • Creating a dynamic two-column iOS spinning wheel with HTML/Javascript

    - by JSW189
    I am trying to create a dynamic two-column spinning wheel for iOS Safari using this HTML/Javascript wheel. However, I am having trouble getting the value of the first column to change the results of the second column. I have tried using an if statement to get the value of the first variable (var beverage) and add the value of the second column correspondingly. Does anybody know what I am doing wrong/if there is a better approach? function openBirthDate() { var beverage = { 1:'Coffee', 2:'Soda' }; //THIS IS WHERE I'M HAVING TROUBLE var results = SpinningWheel.getSelectedValues(); if (results.values === 1) { var company = { 1:'Starbucks', 2:'Dunkin Donuts' }; } else { var company = { 1:'Coke', 2:'Pepsi' }; } var size = { 1:'Tall', 2:'Grande', 3:'Venti' }; SpinningWheel.addSlot(type, '', 1); SpinningWheel.addSlot(company, '', 1); SpinningWheel.addSlot(size, '', 1); SpinningWheel.setCancelAction(cancel); SpinningWheel.setDoneAction(done); SpinningWheel.open(); } function done() { var results = SpinningWheel.getSelectedValues(); document.getElementById('result').innerHTML = 'values: ' + results.values.join(' ') + '<br />keys: ' + results.keys.join(', '); } function cancel() { document.getElementById('result').innerHTML = 'cancelled!'; } window.addEventListener('load', function(){ setTimeout(function(){ window.scrollTo(0,0); }, 100); }, true);

    Read the article

  • Unittest and mock

    - by user1410756
    I'm testing with unittest in python and it's ok. Now, I have introduced mock and I need to resolve a question. This is my code: from mock import Mock import unittest class Matematica(object): def __init__(self, op1, op2): self.op1 = op1 self.op2 = op2 def adder(self): return self.op1 + self.op2 def subs(self): return abs(self.op1 - self.op2) def molt(self): return self.op1 * self.op2 def divid(self): return self.op1 / self.op2 class TestMatematica(unittest.TestCase): """Test della classe Matematica""" def testing(self): """Somma""" mat = Matematica(10,20) self.assertEqual(mat.adder(),30) """Sottrazione""" self.assertEqual(mat.subs(),10) class test_mock(object): def __init__(self, matematica): self.matematica = matematica def execute(self): self.matematica.adder() self.matematica.adder() self.matematica.subs() if __name__ == "__main__": result = unittest.TextTestRunner(verbosity=2).run(TestMatematica('testing')) a = Matematica(10,20) b = test_mock(a) b.execute() mock_foo = Mock(b.execute)#return_value = 'rafa') mock_foo() print mock_foo.called print mock_foo.call_count print mock_foo.method_calls This code is functionally and result of print is: True, 1, [] . Now, I need to count how many times are called self.matematica.adder() and self.matematica.subs() . THANKS

    Read the article

  • parse json news feed array android

    - by user1827260
    I have an json feed from bbc in this format { "name": "ticker", "entries": [ { "headline": "text", "prompt": "LATEST", "isBreaking": "false", "mediaType": "Standard", "url": "" }, { "headline": "text", "prompt": "LATEST", "isBreaking": "false", "mediaType": "Standard", "url": "" }, etc........... My code is as follows: ArrayList mylist = new ArrayList(); JSONObject json = JSONfunctions.getJSONfromURL("http:/......"); try{ JSONArray item = json.getJSONArray("entries"); for (int i = 0; i<item.length(); i++) { HashMap<String, String> map = new HashMap<String, String>(); JSONObject e = item.getJSONObject(i); JSONObject title = e.JSONObject("headline"); map.put("title", "Title:" + e.getString("headline"); } It gives me the error "java.lang.String cannot be converted to JSONObject" I also tried leaving out JSONObject title = e.JSONObject("headline"); and it gives me a path error (note

    Read the article

  • Matlab: Optimization by perturbing variable

    - by S_H
    My main script contains following code: %# Grid and model parameters nModel=50; nModel_want=1; nI_grid1=5; Nth=1; nRow.Scale1=5; nCol.Scale1=5; nRow.Scale2=5^2; nCol.Scale2=5^2; theta = 90; % degrees a_minor = 2; % range along minor direction a_major = 5; % range along major direction sill = var(reshape(Deff_matrix_NthModel,nCell.Scale1,1)); % variance of the coarse data matrix of size nRow.Scale1 X nCol.Scale1 %# Covariance computation % Scale 1 for ihRow = 1:nRow.Scale1 for ihCol = 1:nCol.Scale1 [cov.Scale1(ihRow,ihCol),heff.Scale1(ihRow,ihCol)] = general_CovModel(theta, ihCol, ihRow, a_minor, a_major, sill, 'Exp'); end end % Scale 2 for ihRow = 1:nRow.Scale2 for ihCol = 1:nCol.Scale2 [cov.Scale2(ihRow,ihCol),heff.Scale2(ihRow,ihCol)] = general_CovModel(theta, ihCol/(nCol.Scale2/nCol.Scale1), ihRow/(nRow.Scale2/nRow.Scale1), a_minor, a_major, sill/(nRow.Scale2*nCol.Scale2), 'Exp'); end end %# Scale-up of fine scale values by averaging [covAvg.Scale2,var_covAvg.Scale2,varNorm_covAvg.Scale2] = general_AverageProperty(nRow.Scale2/nRow.Scale1,nCol.Scale2/nCol.Scale1,1,nRow.Scale1,nCol.Scale1,1,cov.Scale2,1); I am using two functions, general_CovModel() and general_AverageProperty(), in my main script which are given as following: function [cov,h_eff] = general_CovModel(theta, hx, hy, a_minor, a_major, sill, mod_type) % mod_type should be in strings angle_rad = theta*(pi/180); % theta in degrees, angle_rad in radians R_theta = [sin(angle_rad) cos(angle_rad); -cos(angle_rad) sin(angle_rad)]; h = [hx; hy]; lambda = a_minor/a_major; D_lambda = [lambda 0; 0 1]; h_2prime = D_lambda*R_theta*h; h_eff = sqrt((h_2prime(1)^2)+(h_2prime(2)^2)); if strcmp(mod_type,'Sph')==1 || strcmp(mod_type,'sph') ==1 if h_eff<=a cov = sill - sill.*(1.5*(h_eff/a_minor)-0.5*((h_eff/a_minor)^3)); else cov = sill; end elseif strcmp(mod_type,'Exp')==1 || strcmp(mod_type,'exp') ==1 cov = sill-(sill.*(1-exp(-(3*h_eff)/a_minor))); elseif strcmp(mod_type,'Gauss')==1 || strcmp(mod_type,'gauss') ==1 cov = sill-(sill.*(1-exp(-((3*h_eff)^2/(a_minor^2))))); end and function [PropertyAvg,variance_PropertyAvg,NormVariance_PropertyAvg]=... general_AverageProperty(blocksize_row,blocksize_col,blocksize_t,... nUpscaledRow,nUpscaledCol,nUpscaledT,PropertyArray,omega) % This function computes average of a property and variance of that averaged % property using power averaging PropertyAvg=zeros(nUpscaledRow,nUpscaledCol,nUpscaledT); %# Average of property for k=1:nUpscaledT, for j=1:nUpscaledCol, for i=1:nUpscaledRow, sum=0; for a=1:blocksize_row, for b=1:blocksize_col, for c=1:blocksize_t, sum=sum+(PropertyArray((i-1)*blocksize_row+a,(j-1)*blocksize_col+b,(k-1)*blocksize_t+c).^omega); % add all the property values in 'blocksize_x','blocksize_y','blocksize_t' to one variable end end end PropertyAvg(i,j,k)=(sum/(blocksize_row*blocksize_col*blocksize_t)).^(1/omega); % take average of the summed property end end end %# Variance of averageed property variance_PropertyAvg=var(reshape(PropertyAvg,... nUpscaledRow*nUpscaledCol*nUpscaledT,1),1,1); %# Normalized variance of averageed property NormVariance_PropertyAvg=variance_PropertyAvg./(var(reshape(... PropertyArray,numel(PropertyArray),1),1,1)); Question: Using Matlab, I would like to optimize covAvg.Scale2 such that it matches closely with cov.Scale1 by perturbing/varying any (or all) of the following variables 1) a_minor 2) a_major 3) theta Thanks.

    Read the article

  • Summing the results of Case queries in SQL

    - by David Stelfox
    I think this is a relatively straightforward question but I have spent the afternoon looking for an answer and cannot yet find it. So... I have a view with a country column and a number column. I want to make any number less than 10 'other' and then sum the 'other's into one value. For example, AR 10 AT 7 AU 11 BB 2 BE 23 BY 1 CL 2 I used CASE as follows: select country = case when number < 10 then 'Other' else country end, number from ... This replaces the countries values with less than 10 in the number column to other but I can't work out how to sum them. I want to end up with a table/view which looks like this: AR 10 AU 11 BE 23 Other 12 Any help is greatly appreciated. Cheers, David

    Read the article

  • How to use pointer from COM object on C#?

    - by Jaeh
    All. I'm trying to use my old dll file on .net project. So I converted this unmanaged COM object to managed one by using [tlbimp.exe] util from Windows SDK. However, one method returns a Object as a return value, but whenever I try to use it, my program generates an error. The weird thing is below: //Object[] item = s.GetObjects(); //this generates an type error Object item = s.GetObjects(); //this works okay System.WriteLine(items); //prints System.Object[] rather than System.Object. It seems like it returns a pointer which contains an object array. Isn't it ? Please anyone tell me how to handle this, and is there any documentation for this issue ?

    Read the article

  • Override tablesorter CSS

    - by user1712810
    I am using jquery tablesorter. When the page loads, I have a code to highlight the background color of certain rows in the table. Since tablesorter is used I guess it overrides the css and not allowing to change the background color of the rows. This is the code. This function automatically loads when the page gets loaded. I removed table-sorter to the table and tried this. It works. I have to get it to work with the table-sorter applied. $(document).ready(function() { var row, len, results; row = 0; results = []; while (row < len) { if ($("#tab1 #example_"+row+"chkbx").is(":checked")) { $("#tab1 #example_" + row).css("background-color", "#c6b79f"); } row++; } return results; });

    Read the article

  • Prolog: using the sort/2 predicate

    - by Øyvind Hauge
    So I'm trying to get rid of the wrapper clause by using the sort library predicate directly inside split. What split does is just generating a list of numbers from a list that looks like this: [1:2,3:2,4:6] ---split-- [1,2,3,2,4,6]. But the generated list contains duplicates, and I don't want that, so I'm using the wrapper to combine split and sort, which then generates the desired result: [1,2,3,4,6]. I'd really like to get rid of the wrapper and just use sort within split, however I keep getting "ERROR: sort/2: Arguments are not sufficiently instantiated." Any ideas? Thanks :) split([],[]). split([H1:H2|T],[H1,H2|NT]) :- split(T,NT). wrapper(L,Processed) :- split(L,L2), sort(L2,Processed).

    Read the article

  • What key on a keyboard can be detected in the browser but won't show up in a text input?

    - by Brady
    I know this one is going to sound weird but hear me out. I have a heart rate monitor that is hooked up like a keyboard to the computer. Each time the heart rate monitor detects a pulse it sends a key stroke. This keystroke is then detected by a web based game running in the browser. Currently I'm sending the following keystroke: (`) In the browser base game I'm detecting the following key fine and if when the user is on any data input screens the (`) character is ignored using a bit of JavaScript. The problem comes when I leave the browser and go back to using the Operating system in other ways the (`) starts appearing everywhere. So my question is: Is there a key that can be sent via the keyboard that is detectable in the browser but wont have any notable output on the screen if I switch to other applications. I'm kind of looking for a null key. A key that is detectable in the browser but has no effect to the browser or any other system application if pressed.

    Read the article

  • Bootstrap - Typehead on multiple inputs

    - by Clem
    I have two text intputs, both have to run an autocompletion. The site is using Bootstrap, and the « typeahead » component. I have this HTML : <input type="text" class="js_typeahead" data-role="artist" /> <input type="text" class="js_typeahead" data-role="location" /> I'm using the « data-role » attribute (that is sent to the Ajax controller as a $_POST index), in order to determine what kind of data has to be retrieved from the database. The Javascript goes this way : var myTypeahead = $('input.js_typeahead').typeahead({ source: function(query, process){ var data_role; data_role = myTypeahead.attr('data-role'); return $.post('/ajax/typeahead', { query:query,data_role:data_role },function(data){ return process(data.options); }); } }); With PHP, I check what $_POST['data-role'] contains, an run the MySQL query (in this case, a query either on a list of Artists, or a list of Locations). But the problem is the second "typeahead" returns the same values than the first one (list of Artists). I assume it's because the listener is attached to the object « myTypeahead », and this way the "data-role" attribute which is used, will always be the same. I think I could fix it by using something like : data_role = $(this).attr('data-role'); But of course this doesn't work, as it's a different scope. Maybe I'm doing it all wrong, but at least maybe you people could give me a hint. Sorry if this has already been discussed, I actually searched but without success. Thanks in advance, Clem (from France, sorry for my english)

    Read the article

  • How add loading image using jquery?

    - by user244394
    I'm working on a form, <form id="myform" class="form"> </form> that gets submitted to the server using jquery ajax. How can I refresh the form on success to show the updated form information and add a spinner until the form loads? here is my html and jquery snippet <div class="container"> <div class="page-header"> <div class="span2"> <!--Sidebar content--> <img src="img/emc_logo.png" title="EMC" > </div> <div class="span6"> <h2 class="form-wizard-heading">Configuration</h2> </div> </div> <form id="myform" class="form"> </form> </div> <!-- /container --> <!-- Modal --> <div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> <h3 id="myModalLabel">Configuration Changes</h3> <p><span class="label label-important">Please review your changes before submitting. Submitting the changes will result in rebooting the cluster</span></p> </div> <div class="modal-body"> <table class="table table-condensed table-striped" id="display"></table> </div> <div class="modal-footer"> <button id="cancel" class="btn" data-dismiss="modal" aria-hidden="true">Close</button> <button id="save" class="btn btn-primary">Save changes</button> </div> </div> //Jquery part $(document).ready(function () { $('input').hover(function () { $(this).popover('show') }); // On mouseout destroy popout $('input').mouseout(function () { $(this).popover('destroy') }); $('#myform').on('submit', function (ev) { ev.preventDefault(); var data = $(this).serializeObject(); json_data = JSON.stringify(data); $('#myModal').modal('show'); $.each(data, function (key, val) { var tablefeed = $('<tr><td>' + key + '</td><td id="' + key + '">' + val + '</td><tr>').appendTo('#display'); }); $(".modal-body").html(tablefeed); }); $("#cancel").click(function () { $("#display").empty(); }); $(function () { $("#save").click(function () { // validate and process form here alert("button submitted" + json_data); $.ajax({ type: "POST", url: "somefile.json.", data: json_data, contentType: 'application/json', success: function (data, textStatus, xhr) { console.log(arguments); console.log(xhr.status); alert("Your form has been submitted: " + textStatus + xhr.status); }, error: function (jqXHR, textStatus, errorThrown) { alert(jqXHR.responseText + " - " + errorThrown + " : " + jqXHR.status); } }); }); }); });

    Read the article

  • Index out of range, but why?

    - by Stuart
    I have a gridview, and i have a SelectedIndexChanged event on it... protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) { GridViewRow Row = GridView1.SelectedRow; //do some stuff } Then i get an error... Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index I dont understand why, the Gridview is being binded in pageload. but not in post back... if (!IsPostBack) { GridView1.DataSource = UserAccounts; GridView1.DataBind(); }

    Read the article

  • PHP $_REQUEST doesn't contain all $_GET varaibles

    - by pinky0x51
    Until today I thought that $_REQUEST always contains all variables form $_POST and $_GET. But today I had the strange experience that one variable is part of $_GET but not part of $_REQUEST. I played a little bit around with the URL which hands over the parameters and it seems like always the fist parameter is missing in the $_REQUEST array. Do you have any idea why this could happen? Thanks! URL: localhost/?app=files&getfile=ajax/newfile.php?dir=%2Ftest4&source=http%3A%2F%2Fl??ocalhost%2Fimg%2Flogo.svg&filename=logo.svg&requesttoken=e250827c341650990cd4

    Read the article

  • C++ Regarding cin.ignore()

    - by user1578897
    i would hope someone can modify my code as its so buggy. sometime its work, sometime it dont.. so let me explain more.. Text file data is as below Line3D, [70, -120, -3], [-29, 1, 268] Line3D, [25, -69, -33], [-2, -41, 58] To read the above line.. i use the following char buffer[30]; cout << "Please enter filename: "; cin.ignore(); getline(cin,filename); readFile.open(filename.c_str()); //if successfully open if(readFile.is_open()) { //record counter set to 0 numberOfRecords = 0; while(readFile.good()) { //input stream get line by line readFile.getline(buffer,20,','); if(strstr(buffer,"Point3D")) { Point3D point3d_tmp; readFile>>point3d_tmp; // and so on... Then i did a overload on the ifstream for Line3d ifstream& operator>>(ifstream &input,Line3D &line3d) { int x1,y1,z1,x2,y2,z2; //get x1 input.ignore(2); input>>x1; //get y1 input.ignore(); input>>y1; //get z1 input.ignore(); input>>z1; //get x2 input.ignore(4); input>>x2; //get y2 input.ignore(); input>>y2; //get z2 input.ignore(); input>>z2; input.ignore(2); Point3D pt1(x1,y1,z1); Point3D pt2(x2,y2,z2); line3d.setPt1(pt1); line3d.setPt2(pt2); line3d.setLength(); } But the issue is the record work sometime and sometime it dont.. what i mean is if at this point //i add a cout cout << x1 << y1 << z1; cout << x2 << y2 << z2; //its works! Point3D pt1(x1,y1,z1); Point3D pt2(x2,y2,z2); line3d.setPt1(pt1); line3d.setPt2(pt2); line3d.setLength(); but if i take away the cout it dont work. how do i change my cin.ignore() so the data can be handle properly , consider number range is -999 to 999

    Read the article

  • Joomla execute script when timeout?

    - by Romain
    My question may be a noob one but: I want to execute a php script when a user timeout. The only way I found to do so is to make the server execute a script every second or minute for instance, get the last activity of every user and execute a script when the last activity is older than (now() - timeout). is this the appropriate solution? Is this will slow the website significantly? Many thanks in advance!

    Read the article

  • Postgres: Find table foreign keys (Faster alternative)

    - by Najera
    Is there faster alternative to this: Take almost 1 minute in our server. SELECT tc.constraint_name, tc.table_name, kcu.column_name, ccu.table_name AS foreign_table_name, ccu.column_name AS foreign_column_name FROM information_schema.table_constraints AS tc JOIN information_schema.key_column_usage AS kcu ON tc.constraint_name = kcu.constraint_name JOIN information_schema.constraint_column_usage AS ccu ON ccu.constraint_name = tc.constraint_name WHERE constraint_type = 'FOREIGN KEY' AND tc.table_name='mytable'; Maybe using pg_class metadata?, thanks.

    Read the article

  • I set a global bug catcher in my application for unhandled exceptions and it is picking up all exceptions

    - by user1632018
    I am trying to figure out why this is happing. In my vb.net application I set a global handler in the ApplicationEvents.vb which I thought would only pick up any unhandled exceptions, although it is picking up every exception that happens in my application whether or not they are handled with try catch blocks. Here is my code in applicationevents Private Sub MyApplication_UnhandledException(ByVal _ sender As Object, ByVal e As _ Microsoft.VisualBasic.ApplicationServices.UnhandledExceptionEventArgs) _ Handles Me.UnhandledException e.ExitApplication = _ MessageBox.Show(e.Exception.Message & _ vbCrLf & "The application has encountered a bug, would you like to Continue?", "An Error has occured.", _ MessageBoxButtons.YesNo, _ MessageBoxIcon.Question) _ = DialogResult.No End Sub In the rest of my application I set normal try catch blocks like this: Try Catch ex as exception End Try Can anyone tell me why this is happening?

    Read the article

  • performance issue: difference between select s.* vs select *

    - by kamil
    Recently I had some problem in performance of my query. The thing is described here: poor Hibernate select performance comparing to running directly - how debug? After long time of struggling, I've finally discovered that the query with select prefix like: select sth.* from Something as sth... Is 300x times slower then query started this way: select * from Something as sth.. Could somebody help me, and asnwer why is that so? Some external documents on this would be really useful. The table used for testing was: SALES_UNIT table contains some basic info abot sales unit node such as name and etc. The only association is to table SALES_UNIT_TYPE, as ManyToOne. The primary key is ID and field VALID_FROM_DTTM which is date. SALES_UNIT_RELATION contains relation PARENT-CHILD between sales unit nodes. Consists of SALES_UNIT_PARENT_ID, SALES_UNIT_CHILD_ID and VALID_TO_DTTM/VALID_FROM_DTTM. No association with any tables. The PK here is ..PARENT_ID, ..CHILD_ID and VALID_FROM_DTTM The actual query I've done was: select s.* from sales_unit s left join sales_unit_relation r on (s.sales_unit_id = r.sales_unit_child_id) where r.sales_unit_child_id is null select * from sales_unit s left join sales_unit_relation r on (s.sales_unit_id = r.sales_unit_child_id) where r.sales_unit_child_id is null Same query, both uses left join and only difference is with select.

    Read the article

  • Trouble updating my datagrid in WPF

    - by wrigley06
    As the title indicates, I'm having trouble updating a datagrid in WPF. Basically what I'm trying to accomplish is a datagrid, that is connected to a SQL Server database, that updates automatically once a user enters information into a few textboxes and clicks a submit button. You'll notice that I have a command that joins two tables. The data from the Quote_Data table will be inserted by a different user at a later time. For now my only concern is getting the information from the textboxes and into the General_Info table, and from there into my datagrid. The code, which I'll include below compiles fine, but when I hit the submit button, nothing happens. This is the first application I've ever built working with a SQL Database so many of these concepts are new to me, which is why you'll probably look at my code and wonder what is he thinking. public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } public DataSet mds; // main data set (mds) private void Window_Loaded_1(object sender, RoutedEventArgs e) { try { string connectionString = Sqtm.Properties.Settings.Default.SqtmDbConnectionString; using (SqlConnection connection = new SqlConnection(connectionString)) { connection.Open(); //Merging tables General_Info and Quote_Data SqlCommand cmd = new SqlCommand("SELECT General_Info.Quote_ID, General_Info.Open_Quote, General_Info.Customer_Name," + "General_Info.OEM_Name, General_Info.Qty, General_Info.Quote_Num, General_Info.Fab_Drawing_Num, " + "General_Info.Rfq_Num, General_Info.Rev_Num, Quote_Data.MOA, Quote_Data.MOQ, " + "Quote_Data.Markup, Quote_Data.FOB, Quote_Data.Shipping_Method, Quote_Data.Freight, " + "Quote_Data.Vendor_Price, Unit_Price, Quote_Data.Difference, Quote_Data.Vendor_NRE_ET, " + "Quote_Data.NRE, Quote_Data.ET, Quote_Data.STI_NET, Quote_Data.Mfg_Time, Quote_Data.Delivery_Time, " + "Quote_Data.Mfg_Name, Quote_Data.Mfg_Location " + "FROM General_Info INNER JOIN dbo.Quote_Data ON General_Info.Quote_ID = Quote_Data.Quote_ID", connection); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); MainGrid.ItemsSource = dt.DefaultView; mds = new DataSet(); da.Fill(mds, "General_Info"); MainGrid.DataContext = mds.Tables["General_Info"]; } } catch (Exception ex) { MessageBox.Show(ex.Message); } // renaming column names from the database so they are easier to read in the datagrid MainGrid.Columns[0].Header = "#"; MainGrid.Columns[1].Header = "Date"; MainGrid.Columns[2].Header = "Customer"; MainGrid.Columns[3].Header = "OEM"; MainGrid.Columns[4].Header = "Qty"; MainGrid.Columns[5].Header = "Quote Number"; MainGrid.Columns[6].Header = "Fab Drawing Num"; MainGrid.Columns[7].Header = "RFQ Number"; MainGrid.Columns[8].Header = "Rev Number"; MainGrid.Columns[9].Header = "MOA"; MainGrid.Columns[10].Header = "MOQ"; MainGrid.Columns[11].Header = "Markup"; MainGrid.Columns[12].Header = "FOB"; MainGrid.Columns[13].Header = "Shipping"; MainGrid.Columns[14].Header = "Freight"; MainGrid.Columns[15].Header = "Vendor Price"; MainGrid.Columns[16].Header = "Unit Price"; MainGrid.Columns[17].Header = "Difference"; MainGrid.Columns[18].Header = "Vendor NRE/ET"; MainGrid.Columns[19].Header = "NRE"; MainGrid.Columns[20].Header = "ET"; MainGrid.Columns[21].Header = "STINET"; MainGrid.Columns[22].Header = "Mfg. Time"; MainGrid.Columns[23].Header = "Delivery Time"; MainGrid.Columns[24].Header = "Manufacturer"; MainGrid.Columns[25].Header = "Mfg. Location"; } private void submitQuotebtn_Click(object sender, RoutedEventArgs e) { CustomerData newQuote = new CustomerData(); int quantity; quantity = Convert.ToInt32(quantityTxt.Text); string theDate = System.DateTime.Today.Date.ToString("d"); newQuote.OpenQuote = theDate; newQuote.CustomerName = customerNameTxt.Text; newQuote.OEMName = oemNameTxt.Text; newQuote.Qty = quantity; newQuote.QuoteNumber = quoteNumberTxt.Text; newQuote.FdNumber = fabDrawingNumberTxt.Text; newQuote.RfqNumber = rfqNumberTxt.Text; newQuote.RevNumber = revNumberTxt.Text; try { string insertConString = Sqtm.Properties.Settings.Default.SqtmDbConnectionString; using (SqlConnection insertConnection = new SqlConnection(insertConString)) { insertConnection.Open(); SqlDataAdapter adapter = new SqlDataAdapter(Sqtm.Properties.Settings.Default.SqtmDbConnectionString, insertConnection); SqlCommand updateCmd = new SqlCommand("UPDATE General_Info " + "Quote_ID = @Quote_ID, " + "Open_Quote = @Open_Quote, " + "OEM_Name = @OEM_Name, " + "Qty = @Qty, " + "Quote_Num = @Quote_Num, " + "Fab_Drawing_Num = @Fab_Drawing_Num, " + "Rfq_Num = @Rfq_Num, " + "Rev_Num = @Rev_Num " + "WHERE Quote_ID = @Quote_ID"); updateCmd.Connection = insertConnection; System.Data.SqlClient.SqlParameterCollection param = updateCmd.Parameters; // // Add new SqlParameters to the command. // param.AddWithValue("Open_Quote", newQuote.OpenQuote); param.AddWithValue("Customer_Name", newQuote.CustomerName); param.AddWithValue("OEM_Name", newQuote.OEMName); param.AddWithValue("Qty", newQuote.Qty); param.AddWithValue("Quote_Num", newQuote.QuoteNumber); param.AddWithValue("Fab_Drawing_Num", newQuote.FdNumber); param.AddWithValue("Rfq_Num", newQuote.RfqNumber); param.AddWithValue("Rev_Num", newQuote.RevNumber); adapter.UpdateCommand = updateCmd; adapter.Update(mds.Tables[0]); mds.AcceptChanges(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } Thanks in advance to anyone who can help, I really appreciate it, Andrew

    Read the article

  • Unable to access LinkedIn conections using python rauth library

    - by srinath sastry
    I was trying out this example at https://github.com/litl/rauth/blob/master/examples/linkedin-web.py I get a 403, Access to connections denied error and it returns KeyError: '_total'. r_network option is present. Has anyone faced this issue? Also if you look at http://docs.python-requests.org/en/latest/user/quickstart/#oauth-authentication, the 'requests' library is initializing resource_owner_key, resource_owner_secret apart from the application keys. Not sure how these are getting passed from the 'rauth' library, Was wondering if that was causing this 403 error.

    Read the article

  • How to use SynonymFilterFactory in Solr?

    - by AlxVallejo
    I'm trying to execute synonym filtering at query time so that if I search for X, results for Y also show up. I go to where Solr is being run, edit the .txt file and add X, Y on a new line. This does not work. I check the schema and I see: <analyzer type="query"> <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true" /> What am I missing? EDIT Assessing configuration files tomcat6/Catalina/localhost seems to point to the correct location <Context docBase="/data/solr/solr.war" debug="0" privileged="true" allowLinking="true" crossContext="true"> <Environment name="solr/home" type="java.lang.String" value="/data/solr" override="true" /> </Context> Also, in the Solr admin I see this. What does cwd mean? cwd=/usr/share/tomcat6 SolrHome=/data/solr/

    Read the article

  • Usage CursorLoader without ContentProvider

    - by sealskej
    Android SDK documentation says that startManagingCursor() method is depracated: This method is deprecated. Use the new CursorLoader class with LoaderManager instead; this is also available on older platforms through the Android compatibility package. This method allows the activity to take care of managing the given Cursor's lifecycle for you based on the activity's lifecycle. That is, when the activity is stopped it will automatically call deactivate() on the given Cursor, and when it is later restarted it will call requery() for you. When the activity is destroyed, all managed Cursors will be closed automatically. If you are targeting HONEYCOMB or later, consider instead using LoaderManager instead, available via getLoaderManager() So I would like to use CursorLoader. But how can I use it with custom CursorAdapter and without ContentProvider, when I needs URI in constructor of CursorLoader?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >