Tag Archives: database

Test connection to access database using oledbconnection in C#

  using System; using System.Data; using System.Data.OleDb;   public class Connect { public static void Main () { String connect = "Provider=Microsoft.JET.OLEDB.4.0;data source=.\\my.mdb"; OleDbConnection con = new OleDbConnection(connect); con.Open(); Console.WriteLine("Made the connection to the access database"); con.Close(); } }

Posted in Access | Tagged , | Leave a comment

Opening a connection to access database in c#

To create a connection between a database and the web application, the Open() method of the Connection class is called. It is used to open a connection to a data source with the property settings specified by the connection string. … Continue reading

Posted in C# ADO.NET | Tagged , | Leave a comment

Retrieving a database insert Index ID using DBI

#!/usr/bin/perl   use DBI; use strict;   my $username = "dbuser"; my $password = "dbpassword"; my $dsn = "dbi:mysql:goo:192.168.1.10"; my $dbh = DBI->connect($dsn,$username,$password) or die "Cannot connect to database: $DBI::errstr"; my $sth = $dbh->prepare("INSERT INTO urls VALUES (”,’http://www.w3mentor.com/’,'tutorials’,unix_timestamp(),’query words’)"); $sth->execute() … Continue reading

Posted in Modules | Tagged , , | Leave a comment

List Valid DSNs for databases using DBI

#!/usr/bin/perl use strict; use DBI; my @drivers; @drivers = DBI->available_drivers; foreach my $driver (@drivers) { print "$driver driver is available\n"; my @dsns = DBI->data_sources($driver); foreach my $dsn (@dsns) { print "\tDSN: $dsn\n"; } }

Posted in Modules | Tagged , | Leave a comment

List currently installed database drivers using DBI

#!/usr/bin/perl use strict; use DBI; my @drivers; @drivers = DBI->available_drivers(); foreach my $dbd (@drivers) { print "$dbd driver is available\n"; } exit;

Posted in Modules | Tagged , | Leave a comment

Store State in a SQL Server Database in ASP.NET

We can store session information in a SQL Server database. Add the following configuration to the web.config: <sessionState mode="SQLServer" sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes" cookieless="false" timeout="20" /> The .NET Framework comes with a SQL script (InstallSqlState.sql, located in the same directory as machine.config) … Continue reading

Posted in C# ASP.NET | Tagged , | Leave a comment

.NET Framework Data Provider Implementations

.NET Framework Data Provider for ODBC Provides connectivity to any data source that implements an ODBC interface; this includes Microsoft SQL Server, Oracle, and Microsoft Access databases. Data provider classes are contained in the System.Data.Odbc namespace and have the prefix … Continue reading

Posted in C# ADO.NET | Tagged , | Leave a comment

MySQL server security measures

Operating system security process can be improved with the following recommendations: Install software as ‘root’ OS user. The file permissions of all MySQL binary and support files are to be owned by ‘root’. Restrict access to the ‘root’ OS user … Continue reading

Posted in MYSQL Administration | Tagged , | 1 Comment

MySQL Security Precautions

Developers/Administrators can improve security for MySQL client access with the following recommendations: Always set a MySQL ‘root’ user password. Change the MySQL ‘root’ user id to a different name, e.g. ‘dba’. Only enable SUPER privileges to dba accounts, and only … Continue reading

Posted in MYSQL Administration | Tagged , | Leave a comment

Store email and username in mysql database using php

<?php //opens connnection to mysql server   $dbc = mysql_connect(’localhost’,'root’,”); if (!dbc){ die(’Not Connected:’ . mysql_error()); } //select a database   $db_selected = mysql_select_db("rivals",$dbc); if(!$db_selected) { die("can’t connect :" . mysql_error()); }   $query = "UPDATE `database` SET email=’something’ WHERE … Continue reading

Posted in PHP Mail | Tagged , , | Leave a comment

Using MySQLi Object Interface with PHP to insert data

The following is an example of using MySQLi Object Interface with PHP to insert data into a database table. $mydb = new mysqli(’localhost’, ‘username’, ‘password’, ‘databasename’); $sql = "INSERT INTO users (fname, lname, comments) VALUES (‘$_POST[fname]‘, ‘$_POST[lname]‘, ‘$_POST[comments]‘)"; if ($mydb->query($sql) … Continue reading

Posted in PHP MYSQL | Tagged , | Leave a comment

Connecting to an ODBC Data Source using CSharp

The ODBC .NET data provider can be used to access data exposed through an ODBC driver. The following example creates an OdbcDataAdapter and uses it to fill a DataTable with the product table. // Namespaces, variables, and constants using System; … Continue reading

Posted in C# ADO.NET | Tagged , | Leave a comment

Drop MySql database

We can drop a mysql database using mysqladmin. A root user or user with special privilege to create or to delete a MySQL database can perform this operation. Here is an example to delete a database: [root@host]# mysqladmin -u root … Continue reading

Posted in MYSQL Administration | Tagged , | Leave a comment

Create MySql Database using mysqladmin

A root user or user with enough privileges can create any database using mysql mysqladmin binary. Here is a simple example to create database called w3m: [root@host]# mysqladmin -u root -p create w3m Enter password:****** This will create a MySQL … Continue reading

Posted in MYSQL Administration | Tagged , , | Leave a comment

Save PHP sessions to a database

We can use the session_set_save_handler() function to register functions that are working with the database. session_set_save_handler() sets the user-level session storage functions which are used for storing and retrieving data associated with a session. This is most useful when a … Continue reading

Posted in PHP sessions | Tagged , , | Leave a comment

Create new Mssql databases with “CREATE DATABASE” statement

Transact-SQL statements can be used to access the database engine directly.To create a database we can use the Query Editor window of the SQL Server management studio. The command to create a database is CREATE DATABASE TestDB GO Additional help … Continue reading

Posted in Transact-SQL | Tagged , | Leave a comment

Upload and store files in Mysql using PHP : Part 2 – PHP file processing

To store uploaded files to MySQL database, you can use the normal INSERT statement as shown in the php example listed below: <?php $con = mysql_connect("localhost", "", ""); mysql_select_db("w3m"); $error = $_FILES[’w3img’][’error’]; $tmp_name = $_FILES[’w3img’][’tmp_name’]; $size = $_FILES[’w3img’][’size’]; $name = … Continue reading

Posted in PHP File Handling | Tagged , , , | Leave a comment

Upload and store files in Mysql using PHP : Part 1 – Design MySql Table

A MySQL database can be used to store files uploaded using PHP.The table columns must be created using BLOB columns to hold the binary file.The blob column can hold up to 65,535 characters. Example code: <?php $con = mysql_connect("localhost", "", … Continue reading

Posted in PHP File Handling | Tagged , , , | 1 Comment

Creating database indexes in PHP MySql

RDBMS like MySql are geared to perform read operations better than write operations. The efficiency in read operations are achieved by database indexes. Indices can have a significant impact on the ability of your applications to manipulate data in a … Continue reading

Posted in PHP MYSQL | Tagged , | 1 Comment

Mysql commands

SHOW DATABASES USE DATABASE SHOW TABLES DESCRIBE TABLE

Posted in MYSQL Basics | Tagged , | Leave a comment