Answers for "sql connection"

5

sql connection c#

private static void CreateCommand(string queryString,
    string connectionString)
{
    using (SqlConnection connection = new SqlConnection(
               connectionString))
    {
        SqlCommand command = new SqlCommand(queryString, connection);
        command.Connection.Open();
        command.ExecuteNonQuery();
    }
}
Posted by: Guest on March-18-2020
2

database connection

Connection = 
  Helps our java project connect to database
Statement = 
  Helps to write and execute SQL query
ResultSet = 
  A DataStructure where the data from query result stored
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    

  After succesfully created the connect
next step is STATEMENT

Statement statement = connection.createStatement();
We use createStatement() method to create
the statement from our connection.
-The result we get from this type of statement
can only move from top to bottom,
not other way around

Statement statement = connection.
createStatement(ResultSet TYPE_SCROLL_INSENSITIVE
,ResultSet CONCUR_READ_ONLY);

-The result we get from this type of
statement can freely move between rows

Once we have statement we can run
the query and get the result to
ResultSet format 
		import java.sql.ResultSet;
        
We use the method executeQuery()
to execute our queries

ResultSet result = statement.
              executeQuery("Select * from employees");
Posted by: Guest on November-28-2020
0

sql database connectivity

<?php
$db_host = "localhost";
$db_user = "your database username";
$db_password = "your database password";
$db_name = "your database name";

$conn =  mysqli_connect($db_host, $db_user, $db_password, $db_name);
// mysql_connect($db_host, $db_user, $db_password) or die('error');
// mysql_select_db('db_name')  or die('db not found');
// echo 'connected';

if(!$conn->connect_error){
    die("connection failed ". mysqli_connect_error());          
}
    // echo"connected";
    if(mysqli_query($conn, $db_name)){
        echo "Database created";
    }else{
        echo "error creating database";
    }
    mysqli_close($conn);


?>
Posted by: Guest on June-13-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language