Ir al contenido principal

Entradas

Mostrando entradas de febrero, 2014

SQL Server - Linked Server

How to import an Excel file using Linked Server 1.- Download the Microsoft Access Database Engine  http://www.microsoft.com/en-us/download/details.aspx?id=13255 In my case I installed the x64 version, to avoid problems I did through the console. Open a cmd console as Administrator Change the path where is your AccessDatabaseEngine_x64.exe file Execute the file adding at the end /passive, example:   C:\Users\ERODVEL\Documents> AccessDatabaseEngine_x64.exe  /passive 2.- Open your SQL Server Management Studio Review that the Provider has been installed Select Microsoft.ACE.OLEDB.12.0 and right click in Properties, and review that the only selected option is "Allow inprocess". Other form is by code     EXEC sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'AllowInProcess', 1 GO Add a new Linked Server using the following code EXEC master.dbo.sp_addlinkedserver     @server = 'ExcelServer2',  ...

SQL Server - Tips

List All Tables of Database   USE [ YourDBName] GO   SELECT   * FROM   sys.Tables GO Insert structure from one table to another SELECT * into new_table FROM origin_table where 1 =2  How to create a counter Use the function ROW_NUMBER ( ), where the syntaxis is   ROW_NUMBER ( ) OVER ( FIELD order_by_clause )   Where FIELD is the name of the column you want to use to start counting. Example: SELECT ROW_NUMBER() OVER(ORDER BY SalesYTD DESC) AS Row, FROM Sales.vSalesPerson   Enumerate rows ... 1.2.3....   ROW_NUMBER() over ( ORDER BY [Job Stage]) as [pyramidPosition]   Reset the enumeration   ..... 1.2.3....1.2.3   ROW_NUMBER() over (partition BY idProject ORDER BY [Job Stage]) as [pyramidPosition]   http://sqlfiddle.com/#!6/501c0/2/0    Update Table from Select   Update projects set projects.tg4Real = [TG4 Date Real DD/MM/YYYY] , projects.tg5R...

Android - First Steps VI

Arrays In your project in the following path: res -> layout folder , create an Android XML file.  Select from the wizard in Resource Type : Values and named the Xml file as "javafacts.xml". The XML file must have the following structure: <?xml version = "1.0" encoding = "utf-8" ?> <resources>     <string-array name=" messages ">         <item> First element </item>          <item> Second element </item>     </string-array> </resources> Get Array in code In this case R.array. messages is by the name in defined in the XML file. Resources resources = this.getResources();         String[] javafacts =  resources.getStringArray(R.array.messages);

Android - First Steps V

Preferences Create XML file Create am Android Xml File  In Resource Type, select Preference In Root Element, select PreferenceScreen Create a class Create a class that extends from PreferenceActivity. Override the method onCreate . Load Preference file Use the method addPreferencesFromResource( R.xml.name_file );. //This method is deprecated in Android version after HoneyComb ( Build.VERSION_CODES.HONEYCOMB ). To knkow the version use: Build.VERSION.SDK_INT  For later version after Honeycomb you need to use a FragmentTransaction and Fragment object, where Fragment receive an inner class that extends from PreferenceFragment . if (savedInstanceState == null) {             FragmentTransaction transaction = getFragmentManager()                     .beginTransaction();             Fragment fragment = new MyPreferencesFr...

Android - First Step IV

Tips Best Image configuration The best quality for image is Bitmap.Config.ARGB_8888 Create a message in the view Toast.makeText(getApplicationContext(), path.toString(),                 Toast.LENGTH_LONG).show();  Permission to storage files <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>  Get external directories         File path = Environment                 .getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);  Count the time         SystemClock.uptimeMillis() Make a pause         postInvalidateDelayed(time_ms) ;  Resources for all screen devices Create a folder inside res folder and then a folder called  drawable-nodpi .  All the resources inside this folder will used without consider the device re...

Android - First Step III

Get Preferences The method help to store information we want to store even after our app has stopped, and return a SharedPreferences object. SharedPreferences pref = getPreferences( MODE_PRIVATE ); The parameter MODE_PRIVATE means that only our app can access to the store information. GET/SET values Use the methods:  pref. getString("key",default_value) pre. setString("key", value) Sleep the interface   It is not recommended to use this command, because all the interface will be frozen until the established time pass.  SystemClock.sleep(time_in_ms);         // SystemClock.sleep(2000); // Never do this!         // Any long-running method will slow down         // the whole look and feel of Android and         // make your app very unresponsive and sluggish   Other option is use  postDelayed method, that execute a Runnable method afte r a speci...

Android - First Step II

Create a ScrollView This view create a scroll in all he view. In activity_main.xml file start with the tag <ScrollView> . Inside the tag <ScrollView> must be another Layout tag <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tools="http://schemas.android.com/tools"     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:paddingBottom="@dimen/activity_vertical_margin"     android:paddingLeft="@dimen/activity_horizontal_margin"     android:paddingRight="@dimen/activity_horizontal_margin"     android:paddingTop="@dimen/activity_vertical_margin"     android:fillViewport="true"     tools:context=".MainActivity" >      <LinearLayout          android:layout_width="match_parent"          android:l...

Android - First Step

Get an element To get an specific element by id use the method findViewById findViewById(R.id.name) After you do a cast to the corresponding type private EditText mName = (EditText) findViewById(R.id.name); Link events with code In the file activity_main.xml inside the object (for example: ImageButton, Button) use the attribute android:onClick="method_name" After in the your Activity class (for example MainActivity.java) declare your method as you named previously (in this case method_name() ), passing as parameter the View .     public void method_name ( View v ) {      //Your code     } Send message in the view ( Toast ) Inside your method create a Toast object and use first the method makeText () and then show() method . Toast . makeText (this.getApplicationContext(), R.string.app_name, Toast.LENGTH_LONG). show (); Animation Inside the activity method (Ex. public void processForm(View view ) {}   ), create the Animation object. ...

C# GridView - How to know which element is

To know an element inside a method call from the view as OnTextChanged method, do a cast to sender parameter. protected void txtOnBoard_TextChanged(object sender , EventArgs e)     {         TextBox txtJs = (TextBox) sender ;         GridViewRow grdrDropDownRow = ((GridViewRow)txtJs. Parent .Parent);     } From sender you also can know how is the Parent element

C# Using tabs

To use tabs in C# use the TabContainer element from AjaxControlToolkit Include AjaxControlToolkit  Include in the Web.config file, inside the tag <system.web> the following code  <pages>       <controls>         <add tagPrefix="ajaxCTK" namespace="AjaxControlToolkit" assembly="AjaxControlToolkit"/>       </controls>     </pages>   Include TabContainer element First  include TabContainer element that is the section where all the tabs will be displayed. <ajaxCTK:TabContainer ID="TabContainerUpdate" runat="server"                 Height="800"                 CssClass="ajax__tab_style"> </ajaxCTK:TabContainer> Second per each tab include the following code corresponding to each ...

Sony not detected on ADT

Configure the cellphone Go to Settings -> Xperia -> Connectivity Select the option Install PC Companion , this option will install the drivers Select the option Usb connetion mode In my case work with Media transfer mode (MTP) that is the default option The recommendations establish change to Mass storage mode (MSC) Restart the computer Restart the ADT Review if you have the drivers installed (Windows) Open a explorer Right click on Computer Select Manage Select Device Manager on left menu  Select Portable Devices Review if you have installed the drivers