Daily Archives

Articles indexed Tuesday March 16 2010

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

  • LPCSTR, TCHAR, String

    - by user285327
    I am use next type of strings: LPCSTR, TCHAR, String i want to convert: 1) from TCHAR to LPCSTR 2) from String to char I convert from TCHAR to LPCSTR by that code: RunPath = TEXT("C:\\1"); LPCSTR Path = (LPCSTR)RunPath; From String to char i convert by that code: SaveFileDialog^ saveFileDialog1 = gcnew SaveFileDialog; saveFileDialog1->Title = "?????????? ?????-????????"; saveFileDialog1->Filter = "bck files (*.bck)|*.bck"; saveFileDialog1->RestoreDirectory = true; pin_ptr<const wchar_t> wch = TEXT(""); if ( saveFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK ) { wch = PtrToStringChars(saveFileDialog1->FileName); } else return; ofstream os(wch, ios::binary); My problem is that when i set "Configuration Properties - General Character Set in "Use Multi-Byte Character Set" the first part of code work correctly. But the second part of code return error C2440. When i set "Configuration Properties - General Character Set in "Use Unicode" the second part of code work correctly. But the first part of code return the only first character from TCHAR to LPCSTR.

    Read the article

  • Removing New line character in Fields PHP

    - by Aruna
    Hi, i am trying to upload an excel file and to store its contents in the Mysql database. i am having a problem in saving the contents.. like My csv file is in the form of "1","aruna","IEEE paper" "2","nisha","JOurnal magazine" actually i am having 2 records and i am using the code <?php $string = file_get_contents( $_FILES["file"]["tmp_name"] ); //echo $string; foreach ( explode( "\n", $string ) as $userString ) { echo $userString; } ? since in the Csv record there is a new line inserted in between IEEE and paper it is dispaying me as 3 records.. How to remove this new line code wise and to modify the code so that only the new line between the records 1 and 2 is considered... Pls help me....

    Read the article

  • Ten latest files on disk

    - by Artic
    I need effective algorithm to keep only ten latest files on disk in particular folder to support some kind of publishing process. Only 10 files should present in this folder at any point of time. Please, give your advises what should be used here.

    Read the article

  • Cost of using repeated parameters

    - by Palimondo
    I consider refactoring few method signatures that currently take parameter of type List or Set of concrete classes --List[Foo]-- to use repeated parameters instead: Foo*. This would allow me to use the same method name and overload it based on the parameter type. This was not possible using List or Set, because List[Foo] and List[Bar] have same type after erasure: List[Object]. In my case the refactored methods work fine with scala.Seq[Foo] that results from the repeated parameter. I would have to change all the invocations and add a sequence argument type annotation to all collection parameters: baz.doStuffWith(foos:_*). Given that switching from collection parameter to repeated parameter is semantically equivalent, does this change have some performance impact that I should be aware of? Is the answer same for scala 2.7._ and 2.8?

    Read the article

  • Django formset doesn't validate

    - by tsoporan
    Hello, I am trying to save a formset but it seems to be bypassing is_valid() even though there are required fields. To test this I have a simple form: class AlbumForm(forms.Form): name = forms.CharField(required=True) The view: @login_required def add_album(request, artist): artist = Artist.objects.get(slug__iexact=artist) AlbumFormSet = formset_factory(AlbumForm) if request.method == 'POST': formset = AlbumFormSet(request.POST, request.FILES) if formset.is_valid(): return HttpResponse('worked') else: formset = AlbumFormSet() return render_to_response('submissions/addalbum.html', { 'artist': artist, 'formset': formset, }, context_instance=RequestContext(request)) And the template: <form action="" method="post" enctype="multipart/form-data">{% csrf_token %} {{ formset.management_form }} {% for form in formset.forms %} <ul class="addalbumlist"> {% for field in form %} <li> {{ field.label_tag }} {{ field }} {{ field.errors }} </li> {% endfor %} </ul> {% endfor %} <div class="inpwrap"> <input type="button" value="add another"> <input type="submit" value="add"> </div> </form> What ends up happening is I hit "add" without entering a name then HttpResponse('worked') get's called seemingly assuming it's a valid form. I might be missing something here, but I can't see what's wrong. What I want to happen is, just like any other form if the field is required to spit out an error if its not filled in. Any ideas?

    Read the article

  • How can I rename a VB6 executable?

    - by parsley72
    I'm trying to automate a VB6 build where different apps are built from the same source by: 1. Changing "Conditional Compilation Arguments". 2. "Make Project" to a different executable name. I can do part of this on the command line: VB6.EXE /m Project.VBP /d BUILD_OTHER_APP=1 but the executable still has the name "Project.exe". If I rename the .EXE it stops working (doesn't seem to run). VB6 doesn't seem to have a command line option to set the executable name and I can't get round this problem with renaming. I'm using VB6 on Win7 32-bit.

    Read the article

  • Why LINQ will work this way?

    - by Benny
    public static ArrayList GetStudentAsArrayList() { ArrayList students = new ArrayList { new Student() { RollNumber = 1,Name ="Alex " , Section = 1 ,HostelNumber=1 }, new Student() { RollNumber = 2,Name ="Jonty " , Section = 2 ,HostelNumber=2 }, }; return students; } this doesn't compile: ArrayList is not IEnumerable ArrayList lstStudents = GetStudentAsArrayList(); var res = from r in lstStudents select r; but this will compile: ArrayList lstStudents = GetStudentAsArrayList(); var res = from Student r in lstStudents select r; Can anybody explain? what's the magic here?

    Read the article

  • Source of UIView Implicit Animation delay?

    - by iPhoneToucher
    I have a block of UIView animation code that looks like this: [UIView beginAnimations:@"pushView" context:nil]; [UIView setAnimationDelay:0]; [UIView setAnimationDuration:.5]; [UIView setAnimationDelegate:self]; [UIView setAnimationWillStartSelector:@selector(animationWillStart)]; view.frame = CGRectMake(0, 0, 320, 416); [UIView commitAnimations]; The code basically mimics the animation of a ModalView presentation and is tied to a button on my interface. When the button is pressed, I get a long (.5 sec) delay (on iPod Touch...twice as fast on iPhone 3GS) before the animationWillStart: actually gets called. My app has lots going on besides this, but I've timed various points of my code and the delay definitely occurs at this block. In other words, a timestamp immediately before this code block and a timestamp when animationWillStart: gets called shows a .5 sec difference. I'm not too experienced with Core Animation and I'm just trying to figure out what the cause of the delay is...Memory use is stable when the animation starts and CoreAnimation FPS seems to be fine in Instruments. The view that gets animated does have upwards of 20 total subviews, but if that were the issue wouldn't it cause choppiness after the animation starts, rather than before? Any ideas?

    Read the article

  • Good PHP ORM Library?

    - by sgibbons
    Does anyone know of a good object-relational-mapping library for PHP? I know of PDO/ADO, but they seem to only provide abstraction of differences between database vendors not an actual mapping between the domain model and the relational model. I'm looking for a PHP library that functions similarly to the way Hibernate does for Java/.Net.

    Read the article

  • How to implement Object Databases in Asp.net MVC(c#)

    - by amexn
    I started my project in Asp.net MVC(c#) & MSSQL 2005.I want to implement Object Databases in my project. While searched in google i found "MongoDb" I didn't have enough knowledge in Object Databases & which one best suited for MSSQL 2005. Please suggest a good example/reference regarding Object Databases implementation in Asp.net MVC application

    Read the article

  • A few questions about a Rails model for a simple addressbook app

    - by user284194
    I have a Rails application that lists information about local services. My objectives for this model are as follows: 1. Require the name and tag_list fields. 2. Require one or more of the tollfreephone, phone, phone2, mobile, fax, email or website fields. 3. If the paddress field has a value, then encode it with the Geokit plugin. Here is my entry.rb model: class Entry < ActiveRecord::Base validates_presence_of :name, :tag_list validates_presence_of :tollfreephone or :phone or :phone2 or :mobile or :fax or :email or :website acts_as_taggable_on :tags acts_as_mappable :auto_geocode=>{:field=>:paddress, :error_message=>'Could not geocode physical address'} before_save :geocode_paddress validate :required_info def required_info unless phone or phone2 or tollfreephone or mobile or fax or email or website errors.add_to_base "Please have at least one form of contact information." end end private def geocode_paddress #if paddress_changed? geo=Geokit::Geocoders::MultiGeocoder.geocode (paddress) errors.add(:paddress, "Could not Geocode address") if ! geo.success self.lat, self.lng = geo.lat,geo.lng if geo.success #end end end Requiring name and tag_list work, but requiring one (or more) of the tollfreephone, phone, phone2, mobile, fax, email or website fields does not. As for encoding with Geokit, in order to save a record with the model I have to enter an address. Which is not the behavior I want. I would like it to not require the paddress field, but if the paddress field does have a value, it should encode the geocode. As it stands, it always tries to geocode the incoming entry. The commented out "if paddress_changed?" was not working and I could not find something like "if paddress_exists?" that would work. Help with any of these issues would be greatly appreciated. I posted three questions pertaining to my model because I'm not sure if they are preventing each other from working. Thank you for reading my questions.

    Read the article

  • WHoosh (full text search) index problem

    - by Rama Vadakattu
    iam having the following problem with whoosh full text search engine. 1.After syncdb i am creating the intial index from the database objects. 2.it is working fine.I can able to search the data and see the results. 3.after that in one of my view i have added another document (via signals) to the index (during a request --response) 4.that' it from then onwards i could not able to search any data , for which i have successfully found results before adding new document (before step 3) ix = storage.open_index() writer = ix.writer() writer.add_document(.............) I have tried hard to resolve but i could not. Any ideas on how to resolve this problem?

    Read the article

  • Code Alignment In SQL SERVER 2005

    - by user294488
    I am using SQL SERVER MANAGEMENT STUDIO. I want to know the shortcuts for easily aligning the T-SQL Queries and codes in a beautiful format for easy readability and understandablility. Please Let me know how to align the code without using any SQL SERVER FORMATTING / ALIGNING Tools. It is Urgent, Waiting for your kind reply at the earliest possible. Please do give your valuable tips to align the same, right now to align the code i mean to make the code right and left aligned i m using the TAB and SPACE BAR key which becomes very difficult when the length of code is increasing.

    Read the article

  • The problem about use the exist sqlite database,

    - by flybirdtt
    I have a sqlite database, and i put this file in "assets" folder. The code like below, Pls help and tell what's wrong in this code, How to use my own sqlite database. public class DataBaseHelper extends SQLiteOpenHelper { private static String DB_PATH = "/data/data/com.SGMalls/databases/"; private static String DB_NAME = "mallMapv2.sqlite"; private SQLiteDatabase myDataBase; private final Context myContext; public DataBaseHelper(Context context) { super(context, DB_NAME, null, 1); this.myContext = context; } public void createDataBase() throws IOException { File dbDir = new File(DB_PATH); if (!dbDir.exists()) { dbDir.mkdir(); } boolean dbExist = checkDataBase(); if (dbExist) { } else { this.getReadableDatabase(); try { copyDataBase(); } catch (IOException e) { throw new Error("Error copying database"); } } close(); } private boolean checkDataBase() { SQLiteDatabase checkDB = null; boolean isnull=false; try { String myPath = DB_PATH + DB_NAME; checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); } catch (SQLiteException e) { // database does't exist yet. } if (checkDB != null) { isnull=true; checkDB.close(); } return isnull; } private void copyDataBase() throws IOException { InputStream myInput = myContext.getAssets().open(DB_NAME); String outFileName = DB_PATH + DB_NAME; OutputStream myOutput = new FileOutputStream(outFileName); byte[] buffer = new byte[1024]; int length; while ((length = myInput.read(buffer)) > 0) { myOutput.write(buffer, 0, length); } // Close the streams myOutput.flush(); myOutput.close(); myInput.close(); } public void openDataBase() throws SQLException { // Open the database String myPath = DB_PATH + DB_NAME; myDataBase = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); } @Override public synchronized void close() { if (myDataBase != null) myDataBase.close(); super.close(); } @Override public void onCreate(SQLiteDatabase db) { } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { } } public class GetData { private static String DB_PATH = "/data/data/com.SGMalls/databases/mallMapv2.sqlite"; // private static String DB_NAME = "mallMapv2.sqlite"; public static ArrayList<Mall> getMalls() { ArrayList<Mall> mallsList = new ArrayList<Mall>(); SQLiteDatabase malldatabase = SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READONLY); String queryString="select id,title from malls order by title"; Cursor cursor=malldatabase.rawQuery(queryString, null); if(cursor!=null){ cursor.moveToFirst(); while(!cursor.isLast()){ Mall mall=new Mall(); mall.setMallid(cursor.getInt(0)); mall.setMallname(cursor.getString(0)); mallsList.add(mall); cursor.moveToNext(); } } malldatabase.close(); return mallsList; } } The error message: ERROR/Database(725): sqlite3_open_v2("/data/data/com.SGMalls/databases/ mallMapv2.sqlite", &handle, 1, NULL) failed 03-15 22:34:11.747: ERROR/AndroidRuntime(725): Uncaught handler: thread main exiting due to uncaught exception 03-15 22:34:11.766: ERROR/AndroidRuntime(725): java.lang.Error: Error copying database Thanks very much

    Read the article

  • Search algorithm for a sorted double linked list

    - by SalamiArmi
    As a learning excercise, I've just had an attempt at implementing my own 'merge sort' algorithm. I did this on an std::list, which apparently already had the functions sort() and merge() built in. However, I'm planning on moving this over to a linked list of my own making, so the implementation is not particuarly important. The problem lies with the fact that a std::list doesnt have facilities for accessing random nodes, only accessing the front/back and stepping through. I was originally planning on somehow performing a simple binary search through this list, and finding my answer in a few steps. The fact that there are already built in functions in an std::list for performing these kinds of ordering leads me to believe that there is an equally easy way to access the list in the way I want. Anyway, thanks for your help in advance!

    Read the article

  • Thoughts on moving to Maven in an enterprise environment

    - by Josh Kerr
    I'm interested in hearing from those who either A) use Maven in an enterprise environment or B) tried to use Maven in an enterprise environment. I work for a large company that is contemplating bringing in Maven into our environment. Currently we use OpenMake to build/merge and home-grown software to deploy code to 100+ servers running various platforms (eg. WAS and JBoss). OpenMake works fine for us however Maven does have some ideal features, most importantly being dependency management, but is it viable in a large environment? Also what headaches have/did you incur, if any, in maintaining a Maven environment. Side note, I've read http://stackoverflow.com/questions/861382/why-does-maven-have-such-a-bad-rep, http://stackoverflow.com/questions/303853/what-are-your-impressions-of-maven, and a few other posts. It's interesting seeing the split between developers.

    Read the article

  • Hitting a ADO.NET Data Services from WPF client, forms authentication

    - by Soulhuntre
    Hey all! There are a number of questiosn on StackOverflow that ALMOST hit this topic head on, but they are either for other technologies, reference obsolets information or don;t supply an answer that I can suss out. So pardon the almost duplication :) I have a working ADO.NET Data Service, and a WPF client that hits it. Now that they are working fine I want to add authentication / security to the system. My understanding of the steps so far is... Turn on forms authentication and configure it on the server (I have an existing asp.net membership service DB for other aspects of this app, so that isnt a problem) so that it is required for the service URL In WCF apply for and recieve a forms authentication "ticket" as part of a login routine Add that "ticket" to the headers of the ADO.NET service calls in WPF Profit! All well and good - but does anyone have a line on a soup to nuts code sample, using the modern releases of these technologies? Thanks!

    Read the article

  • Trac: Changesets lost after changing SVN repository path

    - by synapse
    Last evening I did some housekeeping on our code repository - basically moved the code from /repo/trunk to /repo/projectname/trunk. I changed the repo path on my trac.ini - after which trac complained the repository needed to be resynced. So I ran: trac-admin /var/trac/projectname resync and all was well. Then I checked the changesets against the ticket and found that trac no longer has a link to show the code against changesets - says "No changeset XXX in repository". Has anyone here had the same issue they managed to solve? I need the broken links to the changeset fixed. Thank you

    Read the article

  • Easiest way of checking if a string consists of unique characters?

    - by serg555
    I need to check in Java if a word consists of unique letters (case insensitive). As straight solution is boring, I came up with: For every char in a string check if indexOf(char) == lastIndexOf(char). Add all chars to HashSet and check if set size == string length. Convert a string to a char array, sort it alphabetically, loop through array elements and check if c[i] == c[i+1]. Currently I like #2 the most, seems like the easiest way. Any other interesting solutions?

    Read the article

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