heresh's Profile User Rating: *****

Reputation: 0 Apprentice
Group:
Members
Active Posts:
16 (0.01 per day)
Joined:
06-February 12
Profile Views:
1,327
Last Active:
User is offline Apr 04 2015 02:04 PM
Currently:
Offline

Previous Fields

Country:
CA
OS Preference:
Windows
Favorite Browser:
Internet Explorer
Favorite Processor:
Who Cares
Favorite Gaming Platform:
XBox
Your Car:
Who Cares
Dream Kudos:
0

Latest Visitors

Icon   heresh h

Posts I've Made

  1. In Topic: c++ mysql help

    Posted 4 Apr 2015

    View Post#define, on 04 April 2015 - 01:18 PM, said:

    Hi, it is likely only 1 record or 0 records are returned. Then resSet->rowsCount() will be 1 or zero, also resSet->next() will be true or false.

    if( resSet->next() )
    {
      // username found
    }
    else
    {
      // username not found
    }
    
    


    The username cannot be in the database and not be in the database at the same time.


    Thank you :)
  2. In Topic: c++ mysql help

    Posted 4 Apr 2015

    no it doesn't crash or produce a error. what I want it to do is insert what the user types (usernameForDatabase) inside the database if It's not already in there. If It's already inside the database then I it will print out an error. the first part works;
     
      if (usernameThatIs == usernameForDatabase)  
       {  
        messageText.setString("username is not available");  
        }  
    
    


    but the second part doesn't work. It should check to see if what the user has typed in matches what is inside the database if it is not then it should insert it inside the database.
      
       if (usernameThatIs != usernameForDatabase)  
    
         {  
      prepStatment.reset(connection->prepareStatement("INSERT INTO user(username,password) VALUES ('" + usernameForDatabase + "','" + passwordForDatabase + "');"));  
    
       prepStatment->executeUpdate();  
    
         }  
    
    





    and here is the rest of the code
    sql::Driver* driver = get_driver_instance();
    	std::auto_ptr<sql::Connection> connection(driver->connect("localhost", "root", "heresh"));
    	connection->setSchema("gamedatabase");
        std::auto_ptr<sql::PreparedStatement> prepStatment;
    	std::auto_ptr<sql::Statement> stmnt(connection->createStatement());
    	std::auto_ptr<sql::ResultSet> resSet;
    	
    

My Information

Member Title:
New D.I.C Head
Age:
22 years old
Birthday:
January 1, 1993
Gender:
Location:
calgary
Programming Languages:
html,css,php,mysql

Contact Information

E-mail:
Private
MSN:
MSN  kurd-unit@hotmail.com
Website URL:
Website URL  http://dbzbattles.22web.net

Friends

heresh hasn't added any friends yet.

Comments

heresh has no profile comments yet. Why not say hello?