So I tried to install Ruby on Rails on my windows 7, but it was strange...
First, I followed this tutorial -> http://rubyonrails.org/download
1) I installed Ruby on my C:\
2) I installed Gem on my C:\
3) I did gem install rails, but it says it needed other gem (activesupport, rack....)
Strange... So I downloaded each missing gem and did gem install rack-1.0.0.gem
Then I could install rails!
4) I installed mySQL and NetBeans.
but impossible to create table (db:migrate), and suddenly I have a blue screen...
In fact there was 2 problems.
1) The drive C:\ is kind of protected for writing (Vista & 7). I uninstalled Ruby and installed it on D:\.
After that, when I did gem install rails, it worked like a charm.
2) I couldn't create tables because mySQL5.1 doesn't like Ruby very well. So you should download a latest library. For more information, please see -> http://forums.aptana.com/viewtopic.php?f=20&t=7563&p=27407&hilit=libmysql.dll#p27407
And that's it!
Friday, June 11, 2010
Saturday, April 17, 2010
VB .net avec win7 x64
So here is one thing that may help other people.
I have Win7 x64 and a VB application using Microsoft Access DB. My version of Office is 2007 32 bits.
The VB application is old, and I have to make it works on VS2008. Before it used OLEDB4.0. When I started the program I had this error: provider is not registered on locale machine.
After searching on the Web, I found out that I needed to install new driver (or provider) from Microsoft Website: 2010 Office System Driver Beta: Data Connectivity Components.
And here is what I understood:
If you want to test your DB connection, check here: "UDL Test" on a 64 bit machine
Here is what was inside my UDL file:
[oledb]
; Everything after this line is an OLE DB initstring
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\xxx\Documents\Visual Studio 2008\Projects\WindowsApplication1\WindowsApplication1\DBMain.mdb;Persist Security Info=False
That's it for now
I have Win7 x64 and a VB application using Microsoft Access DB. My version of Office is 2007 32 bits.
The VB application is old, and I have to make it works on VS2008. Before it used OLEDB4.0. When I started the program I had this error: provider is not registered on locale machine.
After searching on the Web, I found out that I needed to install new driver (or provider) from Microsoft Website: 2010 Office System Driver Beta: Data Connectivity Components.
And here is what I understood:
- download 14.0.4536.1000_AccessDatabaseEngine_none_ship_x86_en-us_exe\AccessDatabaseEngine.exe if your Office is 32bits.
- in the properties of your VB application, go to advanced compile options and choose CPU target: x86
- in the string connection, use: gDB.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=""MDITMain.mdb"";Persist Security Info=False". Do not use "14.0". This is a bug, you can find more information on google
If you want to test your DB connection, check here: "UDL Test" on a 64 bit machine
Here is what was inside my UDL file:
[oledb]
; Everything after this line is an OLE DB initstring
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\xxx\Documents\Visual Studio 2008\Projects\WindowsApplication1\WindowsApplication1\DBMain.mdb;Persist Security Info=False
That's it for now
Friday, March 26, 2010
Android join tables
In my application, I have many tables and for a reason, I had to do a query using "join".
I'll not explain how to access a database, but just so you know, check on Google for
object SQLiteDatabase.
So I was checking at the method query , here is the information:
Parameters
table :The table name to compile the query against.
For example:
That's nice, but what if I want to a "join" ? I need more than 1 table in my query.
Well, at beginning I found CursorJoiner. Nice, I can join 2 cursors. But what if I have 3 or more joins to do ??
In fact, the parameter "table " (function query) can contains many tables (not just one).
For example:
That was not difficult, but the definition of the parameter "table " was not so good.
Another solution would be to use SQLiteQueryBuilder.
I'll not explain how to access a database, but just so you know, check on Google for
object SQLiteDatabase.
So I was checking at the method query , here is the information:
public Cursor query (String table, String[] columns, String selection, String[] selectionArgs, String groupBy, String having, String orderBy)
Parameters
table :The table name to compile the query against.
For example:
Cursor cursor = myDataBase.query(
"myTableA" ,
new String[] { "_id", "name"},
null,null, null, null, null);
That's nice, but what if I want to a "join" ? I need more than 1 table in my query.
Well, at beginning I found CursorJoiner. Nice, I can join 2 cursors. But what if I have 3 or more joins to do ??
In fact, the parameter "table " (function query) can contains many tables (not just one).
For example:
Cursor cursor = myDataBase.query(
"myTableA a, myTableB b",
new String[] { "a._id", "a.name", "b._id", "b.name"},
"a.foreignKey = b._id",
null, null, null, null);
That was not difficult, but the definition of the parameter "table " was not so good.
Another solution would be to use SQLiteQueryBuilder.
SQLiteQueryBuilder myQuery = new SQLiteQueryBuilder();
myQuery.setTables("myTableA, myTableB");
myQuery.appendWhere("a.FK = b._id");
Cursor cursor = myQuery.query(myDataBase, null, null, null, null, null, null);
Tuesday, March 16, 2010
Android: add xml layout dynamically
For the application I'm creating, the user can use "search" function. This function will return a list of castles.
Here is the XML to display one result (/res/layout/element_result.xml). There is 1 button, 2 text fields and 1 image :
Then, I created a XML layout (/res/layout/results.xml) who will contain the list of results. That means, there will be many times element_result.xml inside results.xml. There is a scrollView and a table layout.
Ok, our views are ready. Now how to use them in Java. I read this blog, and that helps me a lot : Android LayoutWidth being disregarded by cascaded use of LayoutInflater.
Here is my activity file:
So the result will look like that :

Note: in results.xml, I created a scrollView because if there is 20 results, the user should be able to scroll down to see all the results.
Note: I used "tableLayout" to be able to add results one under another one.
Here is the XML to display one result (/res/layout/element_result.xml). There is 1 button, 2 text fields and 1 image :
android:id="@+id/layoutElement"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
>
android:id="@+id/btnGo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/go"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
>
android:id="@+id/description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/presentation"
android:layout_alignLeft="@+id/presentation"
>
android:id="@+id/presentation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/image"
>
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
>
Then, I created a XML layout (/res/layout/results.xml) who will contain the list of results. That means, there will be many times element_result.xml inside results.xml. There is a scrollView and a table layout.
android:id="@+id/widget28"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
>
android:id="@+id/scrollResult"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbars="horizontal"
android:layout_above="@+id/btnBack"
android:layout_alignParentLeft="true"
>
android:id="@+id/myTableLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
android:id="@+id/btnBack"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/back"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
>
Ok, our views are ready. Now how to use them in Java. I read this blog, and that helps me a lot : Android LayoutWidth being disregarded by cascaded use of LayoutInflater.
Here is my activity file:
public class ResultActivity extends Activity{
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// "results" is for the xml file "results.xml"
setContentView(R.layout.results);
addElementResult();
}
public void addElementResult() {
// "myTableLayout" is the id of the element in results.xml
TableLayout tl = (TableLayout)findViewById(R.id.myTableLayout);
// we will use service from inflater
LayoutInflater inflater = (LayoutInflater)getSystemService(LAYOUT_INFLATER_SERVICE);
//doing a loop to add many times the same xml
for(int i = 0; i < 17; i++) {
// "element_result" is the name of the xml file "element_result.xml".
// Create the itemView who will be added.
// itemView = element_result.xml
View itemView = inflater.inflate(R.layout.element_result, null);
// get the textView, and set the text to something
TextView t1 = (TextView) itemView.findViewById(R.id.presentation);
t1.setText("something" + i);
TextView t2 = (TextView) itemView.findViewById(R.id.description);
t2.setText("oh oh oh" + i);
//add the itemView
tl.addView(itemView, new TableLayout.LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
}
}
}
So the result will look like that :

Note: in results.xml, I created a scrollView because if there is 20 results, the user should be able to scroll down to see all the results.
Note: I used "tableLayout" to be able to add results one under another one.
Wednesday, March 10, 2010
Android: main.out.xml error
So it's been long time, I'm not doing Ruby anymore.
Now, for myself, I decided to create an Android application. At first, I wanted to create an Iphone application, but only people having a Mac can use the SDK... So let's use the Android SDK!
After doing the tutorial Hello World (see here), I started doing my application. And after a few minutes I had an error...
[2010-03-09 11:32:04 - shiro]Error in an XML file: aborting build.
[2010-03-09 11:32:05 - shiro]res\layout\main.xml:0: error: Resource entry main is already defined.
[2010-03-09 11:32:05 - shiro]res\layout\main.out.xml:0: Originally defined here.
[2010-03-09 11:32:05 - shiro]D:\workspace\shiro\res\layout\main.out.xml:1: error: Error parsing XML: no element found
For information, I'm using Eclipse. Why when I click on "run" I have this error ? Why Eclipse is creating a new file "main.out.xml" and then complain about it ? My application is really small, I didn't write any line of code in my main activity...
Well the error is simple, and it's not related to the application directly. It's a problem with Eclipse. To run the application, I must select the project (root folder) in the left column and then I can click on "run".

I had this error, because I was running the "main.xml". So Eclipse could not do anything with that.
Here is a noobie error, but it was difficult to find the solution...
I guess the next post will also concern Android application. It's always fun to discover new things :)
Wednesday, November 4, 2009
Install Tomcat on Windows 7
I decided to install Tomcat (6.0) on Windows 7 for a project.
I downloaded "apache-tomcat-6.0.20.exe" directly from Tomcat website.
I installed it on "d:\".
Then I started it, but nothing happen, it was always at "stopped".
I check the log file, and I could see "[error] Failed creating java C:\Program Files\Java\jre6\bin\client\jvm.dll"
Copy the file msvcr71.dll (C:\Program Files\Java\jre6\bin\msvcr71.dll) to D:\Tomcat 6.0\bin
This website help me to find this solution: http://mandown.co.nz/development/getting-tomcat-apache-to-run-on-microsoft-windows-7/
If this didn't help you, you can have a look here: http://www.mkyong.com/tomcat/tomcat-error-prunsrvc-failed-creating-java-jvmdll/
I downloaded "apache-tomcat-6.0.20.exe" directly from Tomcat website.
I installed it on "d:\".
Then I started it, but nothing happen, it was always at "stopped".
I check the log file, and I could see "[error] Failed creating java C:\Program Files\Java\jre6\bin\client\jvm.dll"
Copy the file msvcr71.dll (C:\Program Files\Java\jre6\bin\msvcr71.dll) to D:\Tomcat 6.0\bin
This website help me to find this solution: http://mandown.co.nz/development/getting-tomcat-apache-to-run-on-microsoft-windows-7/
If this didn't help you, you can have a look here: http://www.mkyong.com/tomcat/tomcat-error-prunsrvc-failed-creating-java-jvmdll/
Thursday, June 25, 2009
insert date in sqlserver
Recently I saw a strange behavior, and I don't know why. When I create a new object model and set its attributes, if I set the date, then in the DB it shows me the day before.
For example:
After, in Sqlserver management studio:
So why it's not the 25th?? Is there a bad configuration somewhere? Well, I don't know. When I have more time, I'll try to understand why, but for now, to avoid this problem, I'm doing the following:
For example:
abc = ABC.find(:first, :conditions => "id = 1")
puts abc["date"] # 2009-06-25
#let's create a new object 'model' and set the same date as ABC
model = Model.new
model.date = abc["date"]
model.name = "a name"
model.save!
After, in Sqlserver management studio:
select * from model;
--date = 2009-06-24 15:00:00:000
--name = "a name"
So why it's not the 25th?? Is there a bad configuration somewhere? Well, I don't know. When I have more time, I'll try to understand why, but for now, to avoid this problem, I'm doing the following:
model.date = "#{abc["date"] }"
Subscribe to:
Posts (Atom)