Showing posts with label Programming. Show all posts
Showing posts with label Programming. Show all posts
Tuesday, September 21, 2010
Sink the Bismarck
Labels:
Downloads,
game,
JAVA,
Programming,
sink the bismarck
Sunday, April 25, 2010
Basic Backup and Restore for MS SQL Server 2000
Here is a simple tutorial for backup and restore in SQL Server 2000. This tutorial covers the basic procedures in creating backup and restoring databases. In this tutorial, we will be using Northwind Database as our example since it available on the sample databases of SQL Server

Before we backup our database, we have to create a logical backup device for our database.
On the query analyzer, make the database in use by selecting it on the drop down menu or by executing the code:
Now we will create our logical backup device. Make sure the path exists when you execute this. If you execute this without errors it means that you are doing right.
After successful execution, you cannot run this code again since it already exists1
Then we will now backup our database with the following code:
As I said(or typed :o)) earlier, you should make sure that the path you created exists2.
Now we will restore are database based on the backup file we have created.
Notes:
1"Honestly, I haven't figured out yet how to alter that logical backup thing but please stay tuned for updates. You can also post some suggestions for this"-jereme
2. Tip: Or at least tell your front end application to create folders if it does not exist.
Backup
On the query analyzer, make the database in use by selecting it on the drop down menu or by executing the code:
Use Northwind
Now we will create our logical backup device. Make sure the path exists when you execute this. If you execute this without errors it means that you are doing right.
EXEC sp_addumpdevice 'disk', 'NWINDBackup', 'c:\NorthwindSystems\Backup\NWind_backup.bak' --NWINDBackup will be the name of our logical backup drive
After successful execution, you cannot run this code again since it already exists1
Then we will now backup our database with the following code:
As I said(or typed :o)) earlier, you should make sure that the path you created exists2.
BACKUP DATABASE Northwind TO NWINDBackup
Restore
Now we will restore are database based on the backup file we have created.
RESTORE DATABASE Northwind FROM NWINDBackupThe syntax follows as:
RESTORE DATABASE [your db name] FROM [logical drive]
Notes:
1"Honestly, I haven't figured out yet how to alter that logical backup thing but please stay tuned for updates. You can also post some suggestions for this"-jereme
2. Tip: Or at least tell your front end application to create folders if it does not exist.
Friday, April 23, 2010
Opening Another Program in VB.NET
Hey I got this code from the website www.dreamincode.net/forums
This can be useful in opening other applications (especially Microsoft VB.NET applications). The problems is that there are chances of error especially when the program is missing, or the program has been moved.
As a solution to that problem, I suggest that you would make the separate application relative to your executable file so that
moving the whole project to another location whould not affect the path you specified.
Your file path should look like this.
Just make sure that the program is located beside the program you are debugging.
You can do this by adding another project as a reference to your main project so that everytime you compile, the executables automatically
proceed to the bin where they would reside as they are executed.
To add a refecence, you can follow these steps:
If the other program (VB Project) is not yet part of the Solution:
1. go to File > Add Existing project
2. Then select the project file of the program you want to link it with.
You will notice in the solution explorer that another project is added.
Now, you can make that program part of the main program by adding it as a reference.
On your solution explorer, right click your main project, Choose Add reference.
As the add reference dialog opens, choose projects then select the project file of the other program.




Try
Dim p As New System.Diagnostics.Process
'the location of your program
p.StartInfo.FileName = "K:\Uni\Year 2\Visual Basic\Report\MSDN\Absolute Beginner's Series VB Lesson 1\01 VB Code\Lesson01\HelloWorld.exe"
p.Start()
Catch ex As Exception
MsgBox("Error - " + ex.Message)
End Try
This can be useful in opening other applications (especially Microsoft VB.NET applications). The problems is that there are chances of error especially when the program is missing, or the program has been moved.
As a solution to that problem, I suggest that you would make the separate application relative to your executable file so that
moving the whole project to another location whould not affect the path you specified.
Your file path should look like this.
p.StartInfo.FileName = "Your Program.exe" 'your relative path, no need to include the drive location for portability
Just make sure that the program is located beside the program you are debugging.
You can do this by adding another project as a reference to your main project so that everytime you compile, the executables automatically
proceed to the bin where they would reside as they are executed.
To add a refecence, you can follow these steps:
If the other program (VB Project) is not yet part of the Solution:
1. go to File > Add Existing project
2. Then select the project file of the program you want to link it with.
You will notice in the solution explorer that another project is added.
Now, you can make that program part of the main program by adding it as a reference.
On your solution explorer, right click your main project, Choose Add reference.
As the add reference dialog opens, choose projects then select the project file of the other program.
Saturday, April 3, 2010
STEPS IN INTEGRATING HELP FILE IN YOUR VB.NET APPLICATION
1. Place this code inside your sub-menu (when clicked under main menu or button if you choose it instead). Make sure you follow the syntax below:
Help.ShowHelp(Me, [url]);
- Since you use VB as programming language, it should be 'Me' not 'this' because ‘this’ is for C#. By the way, what does it mean is ‘Me’ is your main form which will become the parent of the newly opened help file (in your case, your pdf file).
- Next parameter is ‘url’. In this type of parameter, it requires you to input the whole directory together with your pdf file.. For example, your help file is sample.pdf located at 'c:\program files\system'. Just add sample.pdf at the end of 'c:\program files\system' which becomes 'c:\program files\system\sample.pdf'.
So the final output of your ShowHelp() method is:
Help.ShowHelp(Me, "c:\program files\system\sample.pdf");
But there is one problem on this method if you install it in your client's computer; there is a possibility that his/her computer’s directories are different from yours. So if that's the case, follow this:
1. Place your sample.pdf file inside your project's bin-->debug folder (and bin-->release folder if there is) found in your project folder.
2. Then change your code into this
Help.ShowHelp(Me, Path.GetFullPath("sample.pdf"))
For example this is your whole code
--> You need to import System.IO at the top of your code, like this
Imports System.IO
NOTICE:
- This tutorial will work only in Microsoft Visual Studio esp. 2008 (not sure in 2003 and 2005 because I used Path class which I don’t know if existing in .NET 1.1 and .NET 2.0). 2008 uses .NET 3.5.
- I notice that chm, doc and pdf files will open once after clicking the button or submenu under main menu while txt will open as many times you click it.
Hope that helps! =) Always here to post useful tutorials for you guys!
JAVA to MySQL Connection(ODBC)
Here we are going to discuss how to connect JAVA to MySQL
For portability and general purposes, we will be using the Open Database Connectivity(ODBC). Connecting to MySQL with the use of Open Database is similar to connecting to MS Access only with some additional steps.
Here's a copy of the database(dump file) I used in this tutorial. Just import it into your mysql. Download
1. Download MySQL ODBC Connector. I have a copy for windows users at www.mysqlodbccon.4shared.com . Please refer to the link below for more info.(Don't bother the filename if it says noinstall, you're still going to be installing it anyway)
2. Extract the Zip File and Run Install.bat (see, like I told you... although the batch (.bat) file copies the library(.dll) files into your operating system unlike real installers where they involve file extraction)

3. A message will prompt that the instalation (copying of libraries) was successful.
1. We will now create a Data Source Name(DNS) which will be used as a reference by the program. First go to your control panel then Administrative Tools > Data Sources(ODBC)

2. The ODBC Data Source Dialog will then appear, select the System DSN tab.

3. Click on the Add button then another Dialog Box containing the Drivers will appear. Select MySQL ODBC Driver then click Finish.

4. Another Dialog Box will appear for the final configuration. Just fill up the neccessary inputs, the Data Source Name that you will be using on the text box. The Server should contain the local server name(you can use localhost or your computer name). Enter the user and password fields, and the database that you will be using as source.

5. When your done, click finish and you will notice that the data source has been added on the list of System Data Sources.
We will now explain the coding for connecting to the database
1. First import the neccessary libraries for Database connection, java.sql:
import java.sql.*;
2. Then instantiate your connection variables
3. On your procedural method, create an exception handler
4.In the try block, insert your connection code, First is the forced loading of the Database Driver in Class.forName() followed by the declaration of objects we instantiated earlier.
For a full source code listing:
For more information about MySQL ODBC 5.1 Driver, including
installation instructions, please visit;
http://www.mysql.com/products/myodbc/index.html


For portability and general purposes, we will be using the Open Database Connectivity(ODBC). Connecting to MySQL with the use of Open Database is similar to connecting to MS Access only with some additional steps.
Here's a copy of the database(dump file) I used in this tutorial. Just import it into your mysql. Download
Installing the Driver
1. Download MySQL ODBC Connector. I have a copy for windows users at www.mysqlodbccon.4shared.com . Please refer to the link below for more info.(Don't bother the filename if it says noinstall, you're still going to be installing it anyway)
2. Extract the Zip File and Run Install.bat (see, like I told you... although the batch (.bat) file copies the library(.dll) files into your operating system unlike real installers where they involve file extraction)
3. A message will prompt that the instalation (copying of libraries) was successful.
Setting up the Data Source
1. We will now create a Data Source Name(DNS) which will be used as a reference by the program. First go to your control panel then Administrative Tools > Data Sources(ODBC)
2. The ODBC Data Source Dialog will then appear, select the System DSN tab.
3. Click on the Add button then another Dialog Box containing the Drivers will appear. Select MySQL ODBC Driver then click Finish.
4. Another Dialog Box will appear for the final configuration. Just fill up the neccessary inputs, the Data Source Name that you will be using on the text box. The Server should contain the local server name(you can use localhost or your computer name). Enter the user and password fields, and the database that you will be using as source.
5. When your done, click finish and you will notice that the data source has been added on the list of System Data Sources.
Coding
We will now explain the coding for connecting to the database
1. First import the neccessary libraries for Database connection, java.sql:
import java.sql.*;
2. Then instantiate your connection variables
Connection con; Statement stmt; ResultSet rs;
3. On your procedural method, create an exception handler
try{
//Your Code Goes Here
}catch(Exception e){
System.err.println(e);
}
4.In the try block, insert your connection code, First is the forced loading of the Database Driver in Class.forName() followed by the declaration of objects we instantiated earlier.
//Load the JdbcOdbc Driver
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//Specify the Database URL where the DNS will be and the user and password
con = DriverManager.getConnection("jdbc:odbc:TOY2","root","root");
//Initialize the statement to be used, specify if rows are scrollable
stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
//ResultSet will hold the data retrieved
rs = stmt.executeQuery("SELECT * FROM Humans");
//Display the results
while(rs.next()){
System.out.println(rs.getInt("ID") + " " + rs.getString("LastName") + " " + rs.getString("FirstName"));
}For a full source code listing:
import java.sql.*;
public class ViewingMySQL {
public static void main(String[] args) {
Connection con;
Statement stmt;
ResultSet rs;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:TOY2","root","root");
stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
rs = stmt.executeQuery("SELECT * FROM Humans");
while(rs.next()){
System.out.println(rs.getInt("ID") + " " + rs.getString("LastName") + " " + rs.getString("FirstName"));
}
}catch(Exception e){
System.err.println(e);
}
}
}For more information about MySQL ODBC 5.1 Driver, including
installation instructions, please visit;
http://www.mysql.com/products/myodbc/index.html
Labels:
Connection,
Database,
Download,
JAVA,
JDBC,
MySQL,
ODBC,
Programming
Friday, April 2, 2010
Programming Solutions by Language
"Rosetta Code is a programming chrestomathy site. The idea is to present solutions to the same task in as many different languages as possible, to demonstrate how languages are similar and different, and to aid a person with a grounding in one approach to a problem in learning another. Rosetta Code currently has 387 tasks, and covers 225 languages, though we do not (and cannot) have solutions to every task in every language.
A variety of tasks are listed, and visitors to this site are invited to solve the tasks in the language of their choice. The tasks cover everything from the mundane Empty Program to the classic Towers of Hanoi, the practical User Input, the mathematically-inclined Lucas-Lehmer test, and the involved yet entertaining RCRPG."
//SnailviN -- Based on one of its labels, this site is just for reference. Please do not rely on it too much because you will not experience the problems and will not learn it by yourself. =3 Hope this helps.
A variety of tasks are listed, and visitors to this site are invited to solve the tasks in the language of their choice. The tasks cover everything from the mundane Empty Program to the classic Towers of Hanoi, the practical User Input, the mathematically-inclined Lucas-Lehmer test, and the involved yet entertaining RCRPG."
//SnailviN -- Based on one of its labels, this site is just for reference. Please do not rely on it too much because you will not experience the problems and will not learn it by yourself. =3 Hope this helps.
Thursday, March 18, 2010
SharpDevelop: Open Source Visual Studio .NET
Fot those who are looking for an alternative IDE for Microsoft Visual Studio .NET, something that costs less (actually free), and does not require a lot of hardware specification, this this article may be of help.
SharpDevelop is a free IDE that imitates the user interface of Microsoft Visual Studio. It contains a lot of features similar to Visual Studio such as the project explorer, drag-and-drop design view, resource manager, syntax highlighting... etc. It uses the free distributable .NET Framework for compiling source codes. (So it requires .NET Framework installed first)

SharpDevelop may not posses the same quality and features which may be found at Microsoft Visual Studio but this could also be a good option for starters especially in Visual Basic and C# Programming. Users who are already used to may not feel comfortable because of some features. However, projects in SharpDevelop may still be opened in MS Visual Studio.
SharpDevelop may be downloaded at
icsharpcode.net
Latest Version for Microsoft .NET Framework
.NET Framework Page
SharpDevelop is a free IDE that imitates the user interface of Microsoft Visual Studio. It contains a lot of features similar to Visual Studio such as the project explorer, drag-and-drop design view, resource manager, syntax highlighting... etc. It uses the free distributable .NET Framework for compiling source codes. (So it requires .NET Framework installed first)
SharpDevelop may not posses the same quality and features which may be found at Microsoft Visual Studio but this could also be a good option for starters especially in Visual Basic and C# Programming. Users who are already used to may not feel comfortable because of some features. However, projects in SharpDevelop may still be opened in MS Visual Studio.
SharpDevelop may be downloaded at
icsharpcode.net
Latest Version for Microsoft .NET Framework
.NET Framework Page
Tuesday, November 17, 2009
Using Continue
In Programming languages such as C/C++, JAVA, PHP, Python.. etc the keyword continue is a jump statement like break and goto.
This is used to skip inside an iteration.
An example for this is the following for loop statement that prints all even numbers from 0 - 10.
The code is written in C Language (actually it is more like an algotithm)
so even JAVA programmers can easily translate them.
Another example, for more sophisticated programming, continue may be also used for deleting entries in file manipulation.
This is used to skip inside an iteration.
An example for this is the following for loop statement that prints all even numbers from 0 - 10.
for(int num = 0;num <= 10; num++){
if ((num % 2) > 0)
continue;
printf("%d ", num);
}
The code is written in C Language (actually it is more like an algotithm)
so even JAVA programmers can easily translate them.
Another example, for more sophisticated programming, continue may be also used for deleting entries in file manipulation.
Labels:
C/C++,
Development,
JAVA,
Lesson,
Programming,
Tips,
Tutorials
Friday, November 13, 2009
Downloadable JAVA EBOOKS
Free JAVA Lectures (Slideshow).exe Free Java Lectures
How to Program in JAVA.rar JAVA How to Program - the password in this ebook is itspot.
This is a fully featured book where you can learn Java. The best book I know in that programming language.

Thinking in JAVA
I have a copy of this book and I find it easy to understand because of the detailed explanation.
The JAVA turoial A short course on the basics.chm This book helped me a lot on projects in school
squidoo.com/itebooks
How to Program in JAVA.rar JAVA How to Program - the password in this ebook is itspot.
This is a fully featured book where you can learn Java. The best book I know in that programming language.
Thinking in JAVA
I have a copy of this book and I find it easy to understand because of the detailed explanation.
The JAVA turoial A short course on the basics.chm This book helped me a lot on projects in school
squidoo.com/itebooks
Labels:
Development,
Downloads,
ebooks,
JAVA,
Programming,
Reference
Wednesday, October 21, 2009
C Recommended Books
Title:The C Programming Language ANSI C Version
Author:Kernighan & Ritchie
Publisher:Prentice Hall Software Series
ISBN:0-13-110362-8
Comment:Ideal reference book and goes well beyond the level of this course. It is expensive but the serious C programmer will kick themself if they don't buy this book.
Title:ANSI C - Made Easy
Author:Herbert Schildt
Publisher:Osborne McGraw-Hill
ISBN:0-07-881500-2
Comment:
Title:Learning to Program in C
Author:N. Kantaris
Publisher: Babani
ISBN:0-85934-203-4
Comment:A good cheap beginners guide.
Title:Illustrating ANSI C
Author:Donald Alcock
Publisher:Cambridge University Press
ISBN:0-521-42483-6
Comment:A good book for the mathematically inclined.
Title:C - The Complete Reference
Author:Herbert Schildt
Publisher:Osborne McGraw-Hill
ISBN:0-07-881263-1
Comment:
Title:Numerical Recipies in C
Author:W.H.Press, et al
Comment:An advanced level book with, as the name implies, ready-made solutions to your programming problems.
Author:Kernighan & Ritchie
Publisher:Prentice Hall Software Series
ISBN:0-13-110362-8
Comment:Ideal reference book and goes well beyond the level of this course. It is expensive but the serious C programmer will kick themself if they don't buy this book.
Title:ANSI C - Made Easy
Author:Herbert Schildt
Publisher:Osborne McGraw-Hill
ISBN:0-07-881500-2
Comment:
Title:Learning to Program in C
Author:N. Kantaris
Publisher: Babani
ISBN:0-85934-203-4
Comment:A good cheap beginners guide.
Title:Illustrating ANSI C
Author:Donald Alcock
Publisher:Cambridge University Press
ISBN:0-521-42483-6
Comment:A good book for the mathematically inclined.
Title:C - The Complete Reference
Author:Herbert Schildt
Publisher:Osborne McGraw-Hill
ISBN:0-07-881263-1
Comment:
Title:Numerical Recipies in C
Author:W.H.Press, et al
Comment:An advanced level book with, as the name implies, ready-made solutions to your programming problems.
Labels:
C/C++,
Development,
Programming,
pup taguig,
Reference
Subscribe to:
Posts (Atom)