Daily Archives

Articles indexed Monday January 3 2011

Page 10/33 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • How to negate a predicate function using operator ! in C++?

    - by Chan
    Hi, I want to erase all the elements that do not satisfy a criterion. For example: delete all the characters in a string that are not digit. My solution using boost::is_digit worked well. struct my_is_digit { bool operator()( char c ) const { return c >= '0' && c <= '9'; } }; int main() { string s( "1a2b3c4d" ); s.erase( remove_if( s.begin(), s.end(), !boost::is_digit() ), s.end() ); s.erase( remove_if( s.begin(), s.end(), !my_is_digit() ), s.end() ); cout << s << endl; return 0; } Then I tried my own version, the compiler complained :( error C2675: unary '!' : 'my_is_digit' does not define this operator or a conversion to a type acceptable to the predefined operator I could use not1() adapter, however I still think the operator ! is more meaningful in my current context. How could I implement such a ! like boost::is_digit() ? Any idea? Thanks, Chan Nguyen

    Read the article

  • PyGTK: Trouble with size of ScrolledWindow

    - by canavanin
    Hi everyone! I am using PyGTK and the gtk.Assistant. On one page I have placed a treeview (one column, just strings) in a gtk.ScrolledWindow (I wanted the vertical scrollbar, since the list contains about 35 items). Everything is working fine; the only thing that bugs me is that I have not been able to figure out from the documentation how to set the size of the scrolled window. Currently only three items are displayed at a time; I would like to set this number to 10 or so. Below is the code. As you can see I have tried using a gtk.Adjustment to influence the scrolled window's size, but as - once more - I have been incompetent at retrieving the required info from the documentation, I don't actually know what values should be put into there. self.page7 = gtk.VBox() # The gtk.Adjustment: page_size = gtk.Adjustment(lower=10, page_size=100) # just used some arbitrary numbers here >_< scrolled_win = gtk.ScrolledWindow(page_size) scrolled_win.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) # only display scroll bars when required self.character_traits_treeview = gtk.TreeView() self.character_traits_treestore = gtk.TreeStore(str) self.character_traits_treeview.set_model(self.character_traits_treestore) tc = gtk.TreeViewColumn("Character traits") self.character_traits_treeview.append_column(tc) cr = gtk.CellRendererText() tc.pack_start(cr, True) tc.add_attribute(cr, "text", 0) self.character_trait_selection = self.character_traits_treeview.get_selection() self.character_trait_selection.connect('changed', self.check_number_of_character_trait_selections) self.character_trait_selection.set_mode(gtk.SELECTION_MULTIPLE) self.make_character_traits_treestore() # adding the treeview to the scrolled window: scrolled_win.add(self.character_traits_treeview) self.page7.pack_start(scrolled_win, False, False, 0) self.assistant.append_page(self.page7) self.assistant.set_page_title(self.page7, "Step 7: Select 2-3 character traits") self.assistant.set_page_type(self.page7, gtk.ASSISTANT_PAGE_CONTENT) self.assistant.set_page_complete(self.page7, False) def check_number_of_character_trait_selections(self, blah): # ... def make_character_traits_treestore(self): # ... I know I should RTFM, but as I can't make head or tail of it, and as further searching, too, has been to no avail, I'm just hoping that someone on here can give me a hint. Thanks a lot in advance! PS: Here are the links to: the gtk.ScrolledWindow documentation the gtk.Adjustment documentation

    Read the article

  • styles/style.css No mapping found for HTTP request

    - by sonx
    Hi, it seems my styles folder added under the web folder is not getting mapped by dispatcher servlet on my JSP's. I get WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/onlinebasket/styles/style.css] in DispatcherServlet with name 'onlinebasket' here's my dispatcher servlet <servlet-mapping> <servlet-name>onlinebasket</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> and i this is my CSS URL on JSP <link rel="stylesheet" href="<c:url value="/styles/sytle.css"/>" type="text/css"/> This folder is on the web folder.

    Read the article

  • Change ListView background - strage behaviour

    - by Beasly
    Hi again, I have a problem with changing the background of a view in a ListView. What I need: Change the background image of a row onClick() What actually happens: The background gets changed (selected) after pressing e.g. the first entry. But after scrolling down the 8th entry is selected too. Scroll back to the top the first isn't selected anymore. The second entry is selected now. Continue scrolling and it continues jumping... What i'm dong in the Code: I have channels, and onClick() I toggle an attribute of channel boolean selected and then I change the background. I'm doing this only onClick() thats why I don't get why it's actuelly happening on other entries too. One thing I notices is: It seems to be only the "drawing"-part because the item which get selected "by it self" has still the selected value on false I think it seems to have something to do with the reuse of the views in the custom ListAdapters getView(...) Code of onClick() in ListActivity: @Override protected ViewHolder createHolder(View v) { // createHolder will be called only as long, as the ListView is not // filled TextView title = (TextView) v .findViewById(R.id.tv_title_channel_list_adapter); TextView content = (TextView) v .findViewById(R.id.tv_content_channel_list_adapter); ImageView icon = (ImageView) v .findViewById(R.id.icon_channel_list_adapter); if (title == null || content == null || icon == null) { Log.e("ERROR on findViewById", "Couldn't find Title, Content or Icon"); } ViewHolder mvh = new MyViewHolder(title, content, icon); // We make the views become clickable // so, it is not necessary to use the android:clickable attribute in // XML v.setOnClickListener(new ChannelListAdapter.OnClickListener(mvh) { public void onClick(View v, ViewHolder viewHolder) { // we toggle the enabled state and also switch the the // background MyViewHolder mvh = (MyViewHolder) viewHolder; Channel ch = (Channel) mvh.data; ch.setSelected(!ch.getSelected()); // toggle if (ch.getSelected()) { v.setBackgroundResource(R.drawable.row_blue_selected); } else { v.setBackgroundResource(R.drawable.row_blue); } // TESTING Log.d("onClick() Channel", "onClick() Channel: " + ch.getTitle() + " selected: " + ch.getSelected()); } }); return mvh; } Code of getView(...): @Override public View getView(int position, View view, ViewGroup parent) { ViewHolder holder; // When view is not null, we can reuse it directly, there is no need // to reinflate it. // We only inflate a new View when the view supplied by ListView is // null. if (view == null) { view = mInflater.inflate(mViewId, null); // call own implementation holder = createHolder(view); // TEST // we set the holder as tag view.setTag(holder); } else { // get holder back...much faster than inflate holder = (ViewHolder) view.getTag(); } // we must update the object's reference holder.data = getItem(position); // call the own implementation bindHolder(holder); return view; } I really would appreciate any idea how to solve this! :) If more information is needed please tell me. Thanks in advance!

    Read the article

  • C# Drag and Drop Effect with Overlay/Opaque Image

    - by CallMeLaNN
    Hi, I think this would be simple question and should be asked in the pas few years but unable to google around and dont know if there is a specific keyword. In c# WinForm I want to do drag and drop but I dont want the image of DragDropEffects Move, Copy or whatever. I want to display an image with half opaque. Just like Firefox when dragging an image, you would see the image folowing the mouse pointer like a ghost :) I already Implement DoDragDrop, DragEnter and DragDrop events. I just want to customize the dragging effects with overlay image.

    Read the article

  • C# Attribute XmlIgnore and XamlWriter class - XmlIgnore not working

    - by Horst Walter
    I have a class, containing a property Brush MyBrush marked as [XmlIgnore]. Nevertheless it is serialized in the stream causing trouble when trying to read via XamlReader. I did some tests, e.g. when changing the visibility (to internal) of the Property it is gone in the stream. Unfortunately I cannot do this in my particular scenario. Did anybody have the same issue and? Do you see any way to work around this? Remark: C# 4.0 as far I can tell This is a method from my Unit Test where I do test the XamlSerialization: // buffer to a StringBuilder StringBuilder sb = new StringBuilder(); XmlWriter writer = XmlWriter.Create(sb, settings); XamlDesignerSerializationManager manager = new XamlDesignerSerializationManager(writer) {XamlWriterMode = XamlWriterMode.Expression}; XamlWriter.Save(testObject, manager); xml = sb.ToString(); Assert.IsTrue(!String.IsNullOrEmpty(xml) && !String.IsNullOrEmpty(xml), "Xaml Serialization failed for " + testObject.GetType() + " no xml string available"); xml = sb.ToString(); MemoryStream ms = xml.StringToStream(); object root = XamlReader.Load(ms); Assert.IsTrue(root != null, "After reading from MemoryStream no result for Xaml Serialization"); In one of my classes I use the Property Brush. In the above code this Unit Tests fails because of a Brush object not serializable is the value. When I remove the Setter (as below, the Unit Test passes. Using the XmlWriter (basically same test as above) it works. In the StringBuffer sb I can see that Property Brush is serialized when the Setter is there and not when removed (most likely another check ignoring the Property because of no setter). Other Properties with [XmlIgnore] are ignored as intended. [XmlIgnore] public Brush MyBrush { get { ..... } // removed because of problem with Serialization // set { ... } }

    Read the article

  • Paste a multi-line Java String in Eclipse

    - by Thilo
    Unfortunately, Java has no syntax for multi-line string literals. No problem if the IDE makes it easy to work with constructs like String x = "CREATE TABLE TEST ( \n" + "A INTEGER NOT NULL PRIMARY KEY, \n" ... What is the fastest way to paste a multi-line String from the clipboard into Java source using Eclipse (in a way that it automagically creates code like the above).

    Read the article

  • How do I include the capistrano thinking sphinx tasks when using the gem

    - by Sam Saffron
    Im using the gem for thinking sphinx: sudo gem install freelancing-god-thinking-sphinx \ --source http://gems.github.com So: require 'vendor/plugins/thinking-sphinx/recipes/thinking_sphinx' Which is prescribed on the website does not work. How do I include the capistrano thinking sphinx tasks in my deploy.rb file when using the gem? EDIT Adding: require 'thinking_sphinx/deploy/capistrano' gives me: /usr/lib/ruby/gems/1.8/gems/freelancing-god-thinking-sphinx-1.1.12/lib/thinking_sphinx/deploy/capistrano.rb:1: undefined method `namespace' for main:Object (NoMethodError) from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require' from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:36:in `require' from /usr/lib/ruby/gems/1.8/gems/capistrano-2.5.8/lib/capistrano/configuration/loading.rb:152:in `require'

    Read the article

  • if i have three checkboxes on my asp.net webform ..if 1 is already checked om pageload then..

    - by user559800
    if i have three checkboxes on my asp.net webform ..if 1 is already checked on pageload event then output in textbox would be 2,3 if 2 and three checkbox would be checked ...even after ... i want if the checkboxes are already checked on page load event we have to ignore that checkboxes .... and add recently checked checkboxes checkbox2 and checkbox3 will be entered in textbox 1 as 2,3 I WANT THIS IN VB.NET !!

    Read the article

  • HttpContext.Current.User.Identity.Name loses value

    - by Yagami
    Hi, I am using HttpContext.Current.User.Identity.Name to get a user id from 2 web application i'am developping. the problem is when i'am loggin in teh first application i get always HttpContext.Current.User.Identity.Name value (i put test in Application_AuthenticateRequest event) but when i log in teh 2nd application adn i ty to naviagte trough the 1st application teh HttpContext.Current.User.Identity.Name loses value. Environnement of test : Windows XP / VS.NET 2005 / Authentication forms BTW : both application are deployed in teh same machine Thank you for your help

    Read the article

  • Encoding Problem with Zend Navigation using Zend Translate Spanish in XMLTPX File Special Characters

    - by Routy
    Hello, I have been attempting to use Zend Translate to display translated menu items to the user. It works fine until I introduce special characters into the translation files. I instantiate the Zend_Translate object in my bootstrap and pass it in as a translator into Zend_Navigation: $translate = new Zend_Translate( array('adapter' => 'tmx', 'content' => APPLICATION_PATH .'/languages/translation.tmx', 'locale' => 'es' ) ); $navigation->setUseTranslator($translate); I have used several different adapters (array,tmx) in order to see if that made a difference. I ended up with a TMX file that is encoded using ISO-8859-1 (otherwise that throws an XML parse error when introducing the menu item "Administrar Applicación". <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE tmx SYSTEM "tmx14.dtd"> <tmx version="1.4"> <header creationtoolversion="1.0.0" datatype="tbx" segtype="sentence" adminlang="en" srclang="en" o-tmf="unknown" creationtool="XYZTool" > </header> <body> <tu tuid='link_signout'> <tuv xml:lang="en"><seg>Sign Out</seg></tuv> <tuv xml:lang="es"><seg>Salir</seg></tuv> </tu> <tu tuid='link_signin'> <tuv xml:lang="en"><seg>Login</seg></tuv> <tuv xml:lang="es"><seg>Acceder</seg></tuv> </tu> <tu tuid='Manage Application'> <tuv xml:lang="en"><seg>Manage Application</seg></tuv> <tuv xml:lang="es"><seg>Administrar Applicación</seg></tuv> </tu> </body> </tmx> Once I display the menu in the layout: echo $this->navigation()->menu(); It will display all menu items just fine, EXCEPT the one using special characters. It will simply be blank. NOW - If I use PHP's UTF8-encode inside of the zend framework class 'Menu' which I DO NOT want to do: Line 215 in Zend_View_Helper_Navigation_Menu: if ($this->getUseTranslator() && $t = $this->getTranslator()) { if (is_string($label) && !empty($label)) { $label = utf8_encode($t->translate($label)); } if (is_string($title) && !empty($title)) { $title = utf8_encode($t->translate($title)); } } Then it works. The menu item display correctly and all is joyful. The thing is, I do not want to modify the library. Is there some kind of an encoding setting in either zend translate or zend navigation that I am not finding? Please Help! Zend Library Version: 1.11

    Read the article

  • Pushing a local mercurial repository to a remote server or cloning at server from local

    - by Samaursa
    I have a local repository that I have now decided to push to a remote server (for example, I have a host that allows mercurial repositories and I am also trying to push to bitbucket). The repository has a lot of files and is a little more than 200mb. Locally, I am able to clone the repository without problems. Now I have a lot of changes in this repository, and I have wasted a couple of days trying to figure out how to get the remote server to clone my repository. I cannot get hg serve to work outside of the LAN. I have tried everything. So instead, I created a new repository at the remote servers (both at the host and bitbucket) with nothing in it. Now I am pushing the complete repository that I have locally to these remote locations. So far it has been unsuccessful, as the push operation is stuck on searching for changes and does not give me any other useful output. I have let it go for about an hour with no change. Now my questions is, what am I doing wrong as far as hg serve is concerned? I can access it locally but not remotely (through DynDns - I have configured it properly and the router forwards the ports correctly) so that I can get the server to clone the repository the first time after which I will be pushing to it. My second question is, assuming the clone at server does not work (for example, if I was to push my current repository to bitbucket), is creating an empty repository at the server and then pushing a local repository to the new remote repository ok? Is that the source of the searching for changes problem? Any help in this regard would be greatly appreciated.

    Read the article

  • GSM Cell Towers Location & Triangulation Algorithm (Similar to OpenCellID / Skyhook / Google's MyLocation)

    - by ranabra
    Hi all, assuming I have a Fingerprint DB of Cell towers. The data (including Long. & Lat. CellID, signal strength, etc) is achieved by 'wardriving', similar to OpenCellID.org. I would like to be able to get the location of the client mobile phone without GPS (similar to OpenCellID / Skyhook Wireless/ Google's 'MyLocation'), which sends me info on the Cell towers it "sees" at the moment: the Cell tower connected to, and another 6 neighboring cell towers (assuming GSM). I have read and Googled it for a long time and came across several effective theories, such as using SQL 2008 Spatial capabilities, or using an euclidean algorithm, or Markov Model. However, I am lacking a practical solution, preferably in C# or using SQL 2008 :) The location calculation will be done on the server and not on the client mobile phone. the phone's single job is to send via HTTP/GPRS, the tower it's connected to and other neighboring cell towers. Any input is appreciated, I have read so much and so far haven't really advanced much. Thanx

    Read the article

  • layout messed up once spinner has entries

    - by AndyAndroid
    Hello, I have <LinearLayout android:id="@+id/LinearLayoutPlayer" xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content"> <Spinner android:id="@+id/Spinner01" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="100"></Spinner> <ToggleButton android:text="@+id/ToggleButton01" android:id="@+id/ToggleButton01" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_weight="1"></ToggleButton> </LinearLayout> Which displays a spinner and next to it a toggle button. Everything okay so far. Of course the spinner need some entries, so I add to the spinner the attribute: android:entries="@array/myentries" The problem now is that the toggle button is a bit lower than the spinner and the botton of the toggle button is cut off, maybe 3 or 5 lines of pixels. Anyone an idea what is wrong here? Android is version 2.2 Thanks!

    Read the article

  • are shrink-to-fit table cells possible?

    - by Nano8Blazex
    Let's say I have a menu of a prespecified width... I want each menu item to shrink-to-fit with its contents, with the exception of ONE, which then fills up the remaining space in the menu. so like: Fill | item | item | item So far the closest I've come to achieving this effect is by using display:table-cell; in the css code for each menu item. But the problem is unless I define a width for the "item"s, they all expand to take up the same amount of width in the table. Fill | item | item | item | item Is there any way to have the item spaces shrink to fit the item and have the fill just fill up the rest of the div? I might not have asked this very clearly... I'll clarify if needed.

    Read the article

  • ASP.Net Session Storage provider in 3-layer architecture

    - by Tedd Hansen
    I'm implementing a custom session storage provider in ASP.Net. We have a strict 3-layer architecture and therefore the session storage needs to go through the business layer. Presentation-Business-Database. The business layer is accessed through WPF. The database is MSSQL. What I need is (in order of preference): A commercial/free/open source product that solves this. The source code of a SqlSessionStateStore (custom session store) (not the ODBC-sample on MSDN) that I can modify to use a middle layer. I've tried looking at .Net source through Reflector, but the code is not usable. Note: I understand how to do this. I am looking for working samples, preferably that has been proven to work fine under heavy load. The ODBC sample on MSDN doesn't use the (new?) stored procs that the build in SqlSessionStateStore uses - I'd like to use these if possible (decreases traffic). Edit1: To answer Simons question on more info: ASP.Net Session()-object can be stored in either InProc, ASP.Net State Service or SQL-server. In a secure 3-layer model the presentation layer (web server) does not have direct/physical access to the database layer (SQL-server). And even without the physical limitations, from an architectural standpoint you may not want this. InProc and ASP.Net State Service does not support load balancing and doesn't have fault tolerance. Therefore the only option is to access SQL through webservice middle layer (business layer).

    Read the article

  • jQuery - Drag of elements in areas - then not draggable any more

    - by Tim
    Hello! I have three div areas. Creating an element, which is draggable() with jQuery UI, I can drag it all over the screen. Dropping it in a special area, then I can not drag it any more. I created a full working demo: http://jsbin.com/enusu4/2/ There you can create a draggable element which is placed into the left green area. Dragging it to the middle or right green area, I can not drag the element. I increment the zIndex of the elements, but it does not work. Does anyone can help me, what's wrong? Best Regards.

    Read the article

  • Uploading and Importing CSV file to SQL Server in ASP.NET WebForms

    - by Vincent Maverick Durano
    Few weeks ago I was working with a small internal project  that involves importing CSV file to Sql Server database and thought I'd share the simple implementation that I did on the project. In this post I will demonstrate how to upload and import CSV file to SQL Server database. As some may have already know, importing CSV file to SQL Server is easy and simple but difficulties arise when the CSV file contains, many columns with different data types. Basically, the provider cannot differentiate data types between the columns or the rows, blindly it will consider them as a data type based on first few rows and leave all the data which does not match the data type. To overcome this problem, I used schema.ini file to define the data type of the CSV file and allow the provider to read that and recognize the exact data types of each column. Now what is schema.ini? Taken from the documentation: The Schema.ini is a information file, used to define the data structure and format of each column that contains data in the CSV file. If schema.ini file exists in the directory, Microsoft.Jet.OLEDB provider automatically reads it and recognizes the data type information of each column in the CSV file. Thus, the provider intelligently avoids the misinterpretation of data types before inserting the data into the database. For more information see: http://msdn.microsoft.com/en-us/library/ms709353%28VS.85%29.aspx Points to remember before creating schema.ini:   1. The schema information file, must always named as 'schema.ini'.   2. The schema.ini file must be kept in the same directory where the CSV file exists.   3. The schema.ini file must be created before reading the CSV file.   4. The first line of the schema.ini, must the name of the CSV file, followed by the properties of the CSV file, and then the properties of the each column in the CSV file. Here's an example of how the schema looked like: [Employee.csv] ColNameHeader=False Format=CSVDelimited DateTimeFormat=dd-MMM-yyyy Col1=EmployeeID Long Col2=EmployeeFirstName Text Width 100 Col3=EmployeeLastName Text Width 50 Col4=EmployeeEmailAddress Text Width 50 To get started lets's go a head and create a simple blank database. Just for the purpose of this demo I created a database called TestDB. After creating the database then lets go a head and fire up Visual Studio and then create a new WebApplication project. Under the root application create a folder called UploadedCSVFiles and then place the schema.ini on that folder. The uploaded CSV files will be stored in this folder after the user imports the file. Now add a WebForm in the project and set up the HTML mark up and add one (1) FileUpload control one(1)Button and three (3) Label controls. After that we can now proceed with the codes for uploading and importing the CSV file to SQL Server database. Here are the full code blocks below: 1: using System; 2: using System.Data; 3: using System.Data.SqlClient; 4: using System.Data.OleDb; 5: using System.IO; 6: using System.Text; 7:   8: namespace WebApplication1 9: { 10: public partial class CSVToSQLImporting : System.Web.UI.Page 11: { 12: private string GetConnectionString() 13: { 14: return System.Configuration.ConfigurationManager.ConnectionStrings["DBConnectionString"].ConnectionString; 15: } 16: private void CreateDatabaseTable(DataTable dt, string tableName) 17: { 18:   19: string sqlQuery = string.Empty; 20: string sqlDBType = string.Empty; 21: string dataType = string.Empty; 22: int maxLength = 0; 23: StringBuilder sb = new StringBuilder(); 24:   25: sb.AppendFormat(string.Format("CREATE TABLE {0} (", tableName)); 26:   27: for (int i = 0; i < dt.Columns.Count; i++) 28: { 29: dataType = dt.Columns[i].DataType.ToString(); 30: if (dataType == "System.Int32") 31: { 32: sqlDBType = "INT"; 33: } 34: else if (dataType == "System.String") 35: { 36: sqlDBType = "NVARCHAR"; 37: maxLength = dt.Columns[i].MaxLength; 38: } 39:   40: if (maxLength > 0) 41: { 42: sb.AppendFormat(string.Format(" {0} {1} ({2}), ", dt.Columns[i].ColumnName, sqlDBType, maxLength)); 43: } 44: else 45: { 46: sb.AppendFormat(string.Format(" {0} {1}, ", dt.Columns[i].ColumnName, sqlDBType)); 47: } 48: } 49:   50: sqlQuery = sb.ToString(); 51: sqlQuery = sqlQuery.Trim().TrimEnd(','); 52: sqlQuery = sqlQuery + " )"; 53:   54: using (SqlConnection sqlConn = new SqlConnection(GetConnectionString())) 55: { 56: sqlConn.Open(); 57: SqlCommand sqlCmd = new SqlCommand(sqlQuery, sqlConn); 58: sqlCmd.ExecuteNonQuery(); 59: sqlConn.Close(); 60: } 61:   62: } 63: private void LoadDataToDatabase(string tableName, string fileFullPath, string delimeter) 64: { 65: string sqlQuery = string.Empty; 66: StringBuilder sb = new StringBuilder(); 67:   68: sb.AppendFormat(string.Format("BULK INSERT {0} ", tableName)); 69: sb.AppendFormat(string.Format(" FROM '{0}'", fileFullPath)); 70: sb.AppendFormat(string.Format(" WITH ( FIELDTERMINATOR = '{0}' , ROWTERMINATOR = '\n' )", delimeter)); 71:   72: sqlQuery = sb.ToString(); 73:   74: using (SqlConnection sqlConn = new SqlConnection(GetConnectionString())) 75: { 76: sqlConn.Open(); 77: SqlCommand sqlCmd = new SqlCommand(sqlQuery, sqlConn); 78: sqlCmd.ExecuteNonQuery(); 79: sqlConn.Close(); 80: } 81: } 82: protected void Page_Load(object sender, EventArgs e) 83: { 84:   85: } 86: protected void BTNImport_Click(object sender, EventArgs e) 87: { 88: if (FileUpload1.HasFile) 89: { 90: FileInfo fileInfo = new FileInfo(FileUpload1.PostedFile.FileName); 91: if (fileInfo.Name.Contains(".csv")) 92: { 93:   94: string fileName = fileInfo.Name.Replace(".csv", "").ToString(); 95: string csvFilePath = Server.MapPath("UploadedCSVFiles") + "\\" + fileInfo.Name; 96:   97: //Save the CSV file in the Server inside 'MyCSVFolder' 98: FileUpload1.SaveAs(csvFilePath); 99:   100: //Fetch the location of CSV file 101: string filePath = Server.MapPath("UploadedCSVFiles") + "\\"; 102: string strSql = "SELECT * FROM [" + fileInfo.Name + "]"; 103: string strCSVConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filePath + ";" + "Extended Properties='text;HDR=YES;'"; 104:   105: // load the data from CSV to DataTable 106:   107: OleDbDataAdapter adapter = new OleDbDataAdapter(strSql, strCSVConnString); 108: DataTable dtCSV = new DataTable(); 109: DataTable dtSchema = new DataTable(); 110:   111: adapter.FillSchema(dtCSV, SchemaType.Mapped); 112: adapter.Fill(dtCSV); 113:   114: if (dtCSV.Rows.Count > 0) 115: { 116: CreateDatabaseTable(dtCSV, fileName); 117: Label2.Text = string.Format("The table ({0}) has been successfully created to the database.", fileName); 118:   119: string fileFullPath = filePath + fileInfo.Name; 120: LoadDataToDatabase(fileName, fileFullPath, ","); 121:   122: Label1.Text = string.Format("({0}) records has been loaded to the table {1}.", dtCSV.Rows.Count, fileName); 123: } 124: else 125: { 126: LBLError.Text = "File is empty."; 127: } 128: } 129: else 130: { 131: LBLError.Text = "Unable to recognize file."; 132: } 133:   134: } 135: } 136: } 137: } The code above consists of three (3) private methods which are the GetConnectionString(), CreateDatabaseTable() and LoadDataToDatabase(). The GetConnectionString() is a method that returns a string. This method basically gets the connection string that is configured in the web.config file. The CreateDatabaseTable() is method that accepts two (2) parameters which are the DataTable and the filename. As the method name already suggested, this method automatically create a Table to the database based on the source DataTable and the filename of the CSV file. The LoadDataToDatabase() is a method that accepts three (3) parameters which are the tableName, fileFullPath and delimeter value. This method is where the actual saving or importing of data from CSV to SQL server happend. The codes at BTNImport_Click event handles the uploading of CSV file to the specified location and at the same time this is where the CreateDatabaseTable() and LoadDataToDatabase() are being called. If you notice I also added some basic trappings and validations within that event. Now to test the importing utility then let's create a simple data in a CSV format. Just for the simplicity of this demo let's create a CSV file and name it as "Employee" and add some data on it. Here's an example below: 1,VMS,Durano,[email protected] 2,Jennifer,Cortes,[email protected] 3,Xhaiden,Durano,[email protected] 4,Angel,Santos,[email protected] 5,Kier,Binks,[email protected] 6,Erika,Bird,[email protected] 7,Vianne,Durano,[email protected] 8,Lilibeth,Tree,[email protected] 9,Bon,Bolger,[email protected] 10,Brian,Jones,[email protected] Now save the newly created CSV file in some location in your hard drive. Okay let's run the application and browse the CSV file that we have just created. Take a look at the sample screen shots below: After browsing the CSV file. After clicking the Import Button Now if we look at the database that we have created earlier you'll notice that the Employee table is created with the imported data on it. See below screen shot.   That's it! I hope someone find this post useful! Technorati Tags: ASP.NET,CSV,SQL,C#,ADO.NET

    Read the article

  • Folder redirection GPO doesn't seem to be working

    - by homli322
    I've been trying to set up roaming profiles and folder redirection, but have hit a bit of a snag with the latter. This is exactly what I've done so far: (I have OU permissions and GPO permissions over my division's OU.) Created a group called Roaming-Users in the OU 'Groups' Added a single user (testuser) to the group Using the Group Policy Management tool (via RSAT on Windows 7) I right-clicked on the Groups OU and selected 'Create a GPO in this domain, and Link it here' Added my 'Roaming-Users' group to the Security Filtering section of the policy. Added the Folder Redirection option, specifically for Documents. It is set to redirect to: \myserver\Homes$\%USERNAME%\Documents (Homes$ exists and is sharing-enabled). Right-clicked on the policy under the Groups OU and checked Enforced. Logged into a machine as testuser successfully. Created a simple text file, saved some gibberish, logged off. Remoted into the server with Homes$ on it, noticed that the directory Homes$\testuser was created, but was empty. No text file to be found. From what I've read, I did everything I aught to...but I can't quite figure out the issue. I had no errors when I logged off about syncing issues (offline files is enabled) or anything, so I can only imagine my file should have ended up up on the share. Any ideas? EDIT: Using gpresult /R, I confirmed the user is in fact part of the Roaming-Users group, but does not have the policy applied, if that helps. EDIT 2: Apparently you can't apply GPOs to groups...so I applied to users and used the same security filter to limit it to my test user. Nothing happens as far as redirection goes, but I now have the following error in the event log: Folder redirection policy application has been delayed until the next logon because the group policy logon optimization is in effect

    Read the article

  • Percona system tables corrupted.

    - by Anand Jeyahar
    I am having problems setting up mysql replication with a percona as server. accidentally, took a full dump from mysql and restored it on percona and then started,the replication. now when i stop slave and start slave, i am getting the error "[ERROR] Failed to open the relay log './s5-bin.000003' (relay_log_pos 2029993) 110103 9:15:59 [ERROR] Could not find target log during relay log initialization " But show local variables shows the relay_log variable as set in the cnf file.. But the relay-log variable is set to slave-relay-bin alright. I am able to start mysql as a service. But mysqld_safe fails with error "110103 9:19:39 [ERROR] /usr/sbin/mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 2) 110103 9:19:39 [ERROR] Can't start server: can't create PID file: No such file or directory " Am now lost as to what is the problem.

    Read the article

  • [tcp] :/: RPCPROG_NFS: RPC: Program not registered

    - by frankcheong
    I tried to share the root / from a fedora 9 to a freeBSD while when I tried to mount the / folder it complained with "[tcp] nfs_server:/: RPCPROG_NFS: RPC: Program not registered". I followed the below steps to setup on the fedora nfs server:- Add the below line inside the /etc/exports / nfs_client(rw,no_root_squash,sync) restart the nfs related service service portmapper restart service nfslock restart service nfs restart export the filesystem using the below command:- exportfs -arv On the nfs client, I have troubleshoot using the below command:- rpcinfo -p nfs_server program vers proto port service 100000 2 tcp 111 rpcbind 100000 2 udp 111 rpcbind 100024 1 udp 32816 status 100024 1 tcp 34173 status 100011 1 udp 817 rquotad 100011 2 udp 817 rquotad 100011 1 tcp 820 rquotad 100011 2 tcp 820 rquotad 100003 2 udp 2049 nfs 100003 3 udp 2049 nfs 100021 1 udp 32818 nlockmgr 100021 3 udp 32818 nlockmgr 100021 4 udp 32818 nlockmgr 100005 1 udp 32819 mountd 100005 1 tcp 34174 mountd 100005 2 udp 32819 mountd 100005 2 tcp 34174 mountd 100005 3 udp 32819 mountd 100005 3 tcp 34174 mountd showmount -e nfs_client Exports list on nfs_server: / nfs_client What else did I missed?

    Read the article

  • route to vpn based on destination

    - by inquam
    I have a VPN connection on a Windows 7 machine. It's set up to connect to a server in US. Is it possible, and if so how, to setup so that .com destinations uses the vpn interface and .se destinations uses the "normal" connection? Edit (clarification): This is for outbound connections. I.e. the machine conencts to a server on foo.com and uses the VPN and the machine connects to bar.se and uses the "normal" interface. Let's say foo.com has an IP filter that ensures users are located in USA, if I go through the VPN I get a US ip and everything is fine. But tif all traffic goes this way the bar.se server that has a IP filter ensuring users are in Sweden will complain. So I want to route the traffic depending on server location. US servers through VPN and others through the normal interface.

    Read the article

  • Set Display Refresh Rate in OSX w/o External Utilities

    - by codedonut
    I have an iMac and an LG Flatron connected as a secondary monitor. The recommended resolution for the flatron is 1680x1050 @ 65.290 Hz (horiz), 59.954 Hz (vert). For some reason, OSX is choosing a slightly different set of scan rates and this is currently my best guess of why the monitor goes into power saving mode when connected to the iMac (but works fine on a PC). Now, I resolved this by installing switchResX and fudging the scan rates according to the specs in the manual. But how does one change these rates w/o 3rd party tools? Which config files need editing? Thanks

    Read the article

  • Merge Visio files

    - by David Stratton
    I know I can do this manually by using copy/paste but I'm looking for a simpler way. Does anyone know of a quick and easy way to merge Visio documents? I have several Visio vsd files, all of which are the same internal document type (Flowchart - US Units). Each of these has between 1 and 15 pages. I'd like to combine them all into one Visio file. I'm using Visio for Enterprise Architects (11.4301.8221) so if there's a procedure for doing it in that version, that's what I'm looking for, but a 3rd party tool or a macro would work as well.

    Read the article

  • How to write an autohotkey script to toggle the Show hidden files and folders setting?

    - by Oq
    I would like to make use of a hotkey to toggle the Show hidden files and folders setting. I want to use it on both windowsXp and Windows7. Here is what I got so far: #h:: RegRead, Showall_Status, HKEY_LOCAL_MACHINE, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Folder\Hidden\SHOWALL, CheckedValue, If Showall_Status = 0 RegWrite, REG_DWORD, HKEY_LOCAL_MACHINE, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Folder\Hidden\SHOWALL, CheckedValue, 1 Else RegWrite, REG_DWORD, HKEY_LOCAL_MACHINE, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Folder\Hidden\SHOWALL, CheckedValue, 0 Return Problem is when I run the script it simply does nothing. Not sure what I am missing.

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >