Showing posts with label DB. Show all posts
Showing posts with label DB. Show all posts

Friday, April 13, 2012

SQLite plugin for Eclipse



How to browse an Android SQLite Database from Eclipse Kepler

http://www.youtube.com/watch?feature=player_embedded&v=sAvlV0uw5zc

CellObject SQLite Browser : 
http://www.questoid.com/Download.aspx

Questoid website is down and the jar can be downloaded from : 
http://www.java2s.com/Code/Jar/c/com.questoid.htm
http://www.java2s.com/Code/JarDownload/com.questoid/com.questoid.sqlitebrowser_1.2.0.jar.zip

Requirements and how to use CellObject SQLite & XML Browser at
 http://cellobject.net/Tools/CellObjectSQLiteXMLBrowser.aspx

Java Sources at Google Code :
http://code.google.com/p/cellobject/source/browse/

-----------------------------------
How To Install:

Inside the downloaded .zip/.tar file there's a .jar file named net.cellobject.sqlitexmlbrowser_1.2.0.jar. 
Just copy this jar file into the "plugins" folder of your eclipse installation directory, then restart your eclipse.
That's it.








I needed to create an SQLite database for an Android application I was working on. I wanted to browse the database of my application from within Eclipse, instead of pulling it out and browsing with another application.
If you just want to do a little bit of debugging, see if your tables get created the way you want and similar things, there is a very nice plugin for Eclipse that might fit you:
  • Download  the CellObject SQLite & XML Browser plugin.
  • Unzip it
  • Put the .jar file you just extracted inside your eclipse plugin folder (/plugins)
  • restart Eclipse.
  • Start your emulator or plugin in the device on which you installed the application you want to test
  • Open the DDMS perspective in Eclipse (Window —> open perspective —> other —>DDMS)
  • Select your application database (you find it under data/data/[yourapplicationpackage]/databases)
  • Now click on the icon of CellObject browser on the upper right, it will open the CellObject SQLite Browser View.
Instead of Opening DDMS, we can open the CellObject SQLite & XML browser in our Java perspective itself by opening it from Windows--> Show View --> Other --> Other --> CellObject SQLite Browser...

adb shell
sqlite3 /data/data/com.app.name/databases/DatabaseName.db
adb pull /data/data/com.app.name/databases/DatabaseName.db .
sqlite3 DatabaseName.db



Other solution : 
http://www.mysamplecode.com/2011/06/android-emulator-sqlite-database.html
http://sourceforge.net/projects/sqlitebrowser/
http://sqlitebrowser.sourceforge.net/images/slackware9.jpg
http://sourceforge.net/p/sqlitebrowser/svn/73/tree/trunk/src/


Wednesday, October 19, 2011

Step 2 : From SOAP to WCF-RESTful-POST

From SOAP to WCF-RESTful-POST

Simple step 2 :

http://pantestmb.blogspot.com/2011/02/personpassport4asmx.html

SOAP

[WebMethod(Description = "Method to Add User")]
public bool AddUser(string username, string password, string name, string email)
{
bool returnBool = false;
SqlConnection dbConn = new SqlConnection(connStr);
string sqlStr = "INSERT INTO users(username,password,name,email)
values('" + username + "', '" + password + "', '" + name + "', '" + email + "');";
SqlCommand dbCommand = new SqlCommand(sqlStr,dbConn);
try
{
dbConn.Open();
if (dbCommand.ExecuteNonQuery()!=0)
{
returnBool=true;
}
returnBool=true;
}
catch
{
returnBool=false;
}
dbConn.Close();
return returnBool;
}





WCF REST POST :





    [DataContract(Namespace = "")]
    public class RequestData
    {
        [DataMember]
        public string details { get; set; }
    }


    [DataContract]
    public class PersonData
    {
        [DataMember]
        public string Name { get; set; }


        [DataMember]
        public string User { get; set; }


        [DataMember]
        public string Email { get; set; }


        [DataMember]
        public string Password { get; set; }
    }







        public PersonData AddUser(RequestData rData)
        {
            bool returnBool = false;


            var data = rData.details.Split('|');
            var response = new PersonData
            {
                Name = data[0],
                User = data[1],
                Email = data[2],
                Password = data[3]
            };


            SqlConnection dbConn = new SqlConnection(connStr);
            string sqlStr = "INSERT INTO users(username,name,email,password)
                                values('" + data[0] + "', '" + data[1] + "', '" + data[2] + "', '" + data[3] + "');";

            SqlCommand dbCommand = new SqlCommand(sqlStr, dbConn);
            try
            {
                dbConn.Open();
                if (dbCommand.ExecuteNonQuery() != 0)
                {
                    returnBool = true;
                }
                returnBool = true;
            }
            catch
            {
                returnBool = false;
            }
            dbConn.Close();
            return response;
        }



the result on fiddler





the result on SQL Server DataBase



Full Code on Google.Docs :
https://docs.google.com/document/d/1H0d2gq22-SsTElxI_mBEdAiagEOQL4HPXLInDHLDorg/edit?hl=en_GB

~ a 7z file ~ Visual Web Developer Express 2010 ~ full project :
https://docs.google.com/leaf?id=0BzKVfKe--t_cYTc4MWZkZjMtM2VmYi00OWIyLWJkMDgtN2FmOWE0ZGM4YTY5&hl=en_GB

Dumped Database can be downloaded at :
https://docs.google.com/leaf?id=0BzKVfKe--t_cYjAzOTk5YmEtNjk1ZS00ZTcxLWIzMDgtYTMwMTVlMTQwZDVi&hl=en_GB


Thursday, September 22, 2011

Sample Databases for SQL Server 2008


Northwind and pubs Sample Databases for SQL Server 2000

File Name - SQL2000SampleDb.msi = instnwnd.sql + instpubs.sql 



Running the Scripts Using osql
To run the scripts using osql:
1.              Open a command prompt window.
2.              From the command prompt, use the cd command to navigate to the folder containing the SQL Server 2000 Sample Database Scripts:
3.              cd c:\SQL Server 2000 Sample Databases
4.              Run osql specifying either Instpubs.sql or Instnwnd.sql as the input file. Here are some examples:
·                            To install the Northwind database on a default instance on the same computer:
osql -E -i instnwnd.sql
·                            To install the pubs database on a default instance on a different computer:
osql -E -S ComputerName -i instpubs.sql
·                            To install the Northwind database on a named instance:
osql -E -S ComputerName/InstanceName -i instnwnd.sql

Microsoft SQL Server Community Projects & Samples

SQL Server 2008R2 product code samples are available here. Download the AdventureWorks 2008R2 family of sample databases and AdventureWorks 2008R2 sample databases