Mike B
Mike B
Explore posts from servers
JCHJava Community | Help. Code. Learn.
Created by Mike B on 1/29/2025 in #java-help
Database Connection
ohh ok thanks for the clarification
18 replies
JCHJava Community | Help. Code. Learn.
Created by Mike B on 1/29/2025 in #java-help
Database Connection
but also if anyone else wanted to run the proj on their own how would that work?
18 replies
JCHJava Community | Help. Code. Learn.
Created by Mike B on 1/29/2025 in #java-help
Database Connection
makes sense i just searched it up
18 replies
JCHJava Community | Help. Code. Learn.
Created by Mike B on 1/29/2025 in #java-help
Database Connection
ahh okay
18 replies
JCHJava Community | Help. Code. Learn.
Created by Mike B on 1/29/2025 in #java-help
Database Connection
my plan is to post this project on github though for like my portfolio, sooo would that be the best option?
18 replies
JCHJava Community | Help. Code. Learn.
Created by Mike B on 1/29/2025 in #java-help
Database Connection
im not sure
18 replies
JCHJava Community | Help. Code. Learn.
Created by Mike B on 1/29/2025 in #java-help
Database Connection
how do i protect my password or go about this, I'm using MYSQL
18 replies
JCHJava Community | Help. Code. Learn.
Created by Mike B on 1/29/2025 in #java-help
Database Connection
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/BankifyDB", "root", "");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/BankifyDB", "root", "");
18 replies
CC#
Created by Mike B on 11/10/2024 in #help
Insert into Access Database
public Car(int vehicleID, string make, string model, int year, int mileage, decimal rentalCost, string description, string location, string availablility, string classification, string image)
{
this.vehicleID = vehicleID;
this.make = make;
this.model = model;
this.year = year;
this.mileage = mileage;
this.rentalCost = rentalCost;
this.description = description;
this.location = location;
this.availablility = availablility;
this.classification = classification;
this.image = image;
}
public Car(int vehicleID, string make, string model, int year, int mileage, decimal rentalCost, string description, string location, string availablility, string classification, string image)
{
this.vehicleID = vehicleID;
this.make = make;
this.model = model;
this.year = year;
this.mileage = mileage;
this.rentalCost = rentalCost;
this.description = description;
this.location = location;
this.availablility = availablility;
this.classification = classification;
this.image = image;
}
this is my car class
22 replies
CC#
Created by Mike B on 11/10/2024 in #help
Insert into Access Database
this is my table
22 replies
CC#
Created by Mike B on 11/10/2024 in #help
Insert into Access Database
No description
22 replies
CC#
Created by Mike B on 11/10/2024 in #help
Insert into Access Database
updated and I still recieved the same error
22 replies
CC#
Created by Mike B on 11/10/2024 in #help
Insert into Access Database
string query = "INSERT INTO Cars (VIN, Make, Model, CarYear, Mileage, RentalCost, Description, Location, Availability, Class, Image) " +
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";


OleDbCommand cmd = new OleDbCommand(query, connection);
cmd.Parameters.AddWithValue("?", car.VehicleID);
cmd.Parameters.AddWithValue("?", car.Make);
cmd.Parameters.AddWithValue("?", car.Model);
cmd.Parameters.AddWithValue("?", car.Year);
cmd.Parameters.AddWithValue("?", car.Mileage);
cmd.Parameters.AddWithValue("?", car.RentalCost);
cmd.Parameters.AddWithValue("?", car.Description);
cmd.Parameters.AddWithValue("?", car.Location);
cmd.Parameters.AddWithValue("?", car.Availability);
cmd.Parameters.AddWithValue("?", car.Classification);
cmd.Parameters.AddWithValue("?", car.Image);
OleDbCommand command = new OleDbCommand(query, connection);

command.ExecuteNonQuery();
MessageBox.Show("Car successfully added!");

string query = "INSERT INTO Cars (VIN, Make, Model, CarYear, Mileage, RentalCost, Description, Location, Availability, Class, Image) " +
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";


OleDbCommand cmd = new OleDbCommand(query, connection);
cmd.Parameters.AddWithValue("?", car.VehicleID);
cmd.Parameters.AddWithValue("?", car.Make);
cmd.Parameters.AddWithValue("?", car.Model);
cmd.Parameters.AddWithValue("?", car.Year);
cmd.Parameters.AddWithValue("?", car.Mileage);
cmd.Parameters.AddWithValue("?", car.RentalCost);
cmd.Parameters.AddWithValue("?", car.Description);
cmd.Parameters.AddWithValue("?", car.Location);
cmd.Parameters.AddWithValue("?", car.Availability);
cmd.Parameters.AddWithValue("?", car.Classification);
cmd.Parameters.AddWithValue("?", car.Image);
OleDbCommand command = new OleDbCommand(query, connection);

command.ExecuteNonQuery();
MessageBox.Show("Car successfully added!");

22 replies
CC#
Created by Mike B on 11/10/2024 in #help
Insert into Access Database
One sec let me update the code, I tried it and still have gotten issues
22 replies
CC#
Created by Mike B on 11/10/2024 in #help
Insert into Access Database
this is the info i got from my form and the generated inserts statement 1234, 'Porsche', '911', 2024, 23, 89.99, 'Fast', 'Lot B', 'Available', 'Sport', 'porsche.png' INSERT into Cars(VIN, Make, Model, CarYear, Mileage, RentalCost, Description, Location, Availability, Class, Image) VALUES (1234, 'Porsche', '911', 2024, 23, 89.99, 'Fast', 'Lot B', 'Available', 'Sport', 'porsche.png') Exception thrown: 'System.Data.OleDb.OleDbException' in System.Data.dll
22 replies
CC#
Created by Mike B on 11/10/2024 in #help
Insert into Access Database
internal void AddCar(Car car)
{
OleDbConnection connection = new OleDbConnection(strConnection);


try
{
connection.Open();
Console.WriteLine(car.ToString());

// Use a parameterized query to prevent SQL injection and handle special characters.
string query = "INSERT into Cars(VIN, Make, Model, CarYear, Mileage, RentalCost, Description, Location, Availability, Class, Image) " +
$"VALUES ({car.VehicleID}, '{car.Make}', '{car.Model}', {car.Year}, {car.Mileage}, {car.RentalCost}, '{car.Description}', '{car.Location}', '{car.Availability}', '{car.Classification}', '{car.Image}')";
Console.WriteLine(query);

OleDbCommand command = new OleDbCommand(query, connection);

command.ExecuteNonQuery();

}
catch (Exception ex)
{
MessageBox.Show("Addcar exception: "+ ex.Message);
}
finally
{

Console.WriteLine("connection closing");
connection.Close();
}
}
internal void AddCar(Car car)
{
OleDbConnection connection = new OleDbConnection(strConnection);


try
{
connection.Open();
Console.WriteLine(car.ToString());

// Use a parameterized query to prevent SQL injection and handle special characters.
string query = "INSERT into Cars(VIN, Make, Model, CarYear, Mileage, RentalCost, Description, Location, Availability, Class, Image) " +
$"VALUES ({car.VehicleID}, '{car.Make}', '{car.Model}', {car.Year}, {car.Mileage}, {car.RentalCost}, '{car.Description}', '{car.Location}', '{car.Availability}', '{car.Classification}', '{car.Image}')";
Console.WriteLine(query);

OleDbCommand command = new OleDbCommand(query, connection);

command.ExecuteNonQuery();

}
catch (Exception ex)
{
MessageBox.Show("Addcar exception: "+ ex.Message);
}
finally
{

Console.WriteLine("connection closing");
connection.Close();
}
}
22 replies
CC#
Created by Mike B on 11/10/2024 in #help
Insert into Access Database
how do i format the code
22 replies
JCHJava Community | Help. Code. Learn.
Created by Mike B on 2/14/2024 in #java-help
Linked List Nodes
Anyone?
12 replies
JCHJava Community | Help. Code. Learn.
Created by Mike B on 2/14/2024 in #java-help
Linked List Nodes
and this is a circular linked list
12 replies
JCHJava Community | Help. Code. Learn.
Created by Mike B on 2/14/2024 in #java-help
Linked List Nodes
without the else if (index ==0), when I try to add a new number as the new head the code puts the number in index 1
12 replies