15,899,754 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by arave0521 (Top 50 by date)
arave0521
23-Jun-14 10:23am
View
the error still the same. but i tried figure it out. and it works fine. but not sure the algorithm can be considered proper or not. here is my code
command.CommandText = "SELECT COUNT(*) FROM " + database +
".Metabolites " +
"WHERE MetaboliteID = " +
"'" + metNo + "'";
command.ExecuteNonQuery();
int count = int.Parse(command.ExecuteScalar().ToString());
if (count > 0)
{
}
else
{
}
arave0521
12-Jun-14 11:09am
View
yes. i tried. but still the same bug. The problem because of my algorithm. I still work out on it.
arave0521
28-May-14 4:21am
View
the problem started when it want to enter the for loop of metabolite class. I had insert the comment of the problem arise
arave0521
28-May-14 4:20am
View
I had insert the comment
arave0521
28-May-14 4:17am
View
I wrote it in one class before and use different methods, but the problem still the same
arave0521
9-May-14 0:39am
View
when I do breakpoint, I found it it the problem because of command.ExecuteNonQuery();inside for looping. It said object reference is not set to instance.
this part of code
conn.Open();
for (i = 0; i < Main.dbMetName.Rows.Count; i++)
{
command.CommandText = "INSERT INTO " + database +
".Metabolites " +
"(MetaboliteID, Metabolite_Name)" +
"VALUES " +
"('" + Main.dbMetName.Rows[i].Cells[0].Value.ToString()
+ "' , '" +
Main.dbMetName.Rows[i].Cells[1].Value.ToString() + "')";
command.ExecuteNonQuery();
}
conn.Close();
where all of declaration of object and variable are made inside constructor. and global part
arave0521
2-Mar-14 11:45am
View
it works. just because I did not set the DataGridView.AllowUserToAddRows = false in the function. sorry for not mentioning at first. thank you so much btw.
arave0521
2-Mar-14 10:49am
View
There is a problem with the code. The code quite similar with the one I tried before and it produce the same error. The error is uncommitted new row cannot be deleted
arave0521
2-Mar-14 10:15am
View
how to remove 1 whole row if let say there are two column and two column has no value. some sort like this code
DataGridView1.Rows.Remove(_row);
arave0521
2-Mar-14 9:22am
View
yes. the first form actually allowed user to add how many row he want. but when it comes to second form which showing the datagridview which only allowed user to edit and not allowed him to add at all.
arave0521
22-Dec-13 0:26am
View
problem solved
thanks !!! :)
arave0521
21-Dec-13 22:31pm
View
User can insert the amount of car more than the availability of car.
However,for second input user cannot enter the case because the amount car is less or equal than 0.
arave0521
12-Nov-13 19:02pm
View
yes. I tried to put dbSumMetabolite.DataSource = null;
It is not working.
arave0521
12-Nov-13 11:25am
View
not working. still produce duplication
arave0521
12-Nov-13 10:25am
View
Hi, It has a bit problem. how to make sure the data is not duplicate when we update? I try put dbSumMetabolite.ResetBindings(); it does not work
arave0521
12-Nov-13 8:46am
View
It works. thanks.
arave0521
12-Nov-13 8:04am
View
There is an error saying that rows cannot be programamtically added to datagridview rows collection when control is data-bound
arave0521
12-Nov-13 7:45am
View
yes. I have predefine the column of the datagridview. 1st column DataPropertyName is "Metabolite ID" and Header Text "Metabolite ID". 2nd Column DataPropertyName is "Metabolite Name" and Header Text is "Metabolite Name"
arave0521
12-Nov-13 7:38am
View
the data is not placed on respective column. what code should i put to make it inserted in respective column
arave0521
12-Nov-13 6:50am
View
I still don't get it. Okay right now I have two predefined column in design. And I want to insert the sql statement based on the respective column. Can you show any tutorial on this. Thanks
arave0521
12-Nov-13 6:37am
View
Hai. may I know more details? I'm quite beginner in mysql and datagridview
arave0521
20-Oct-13 17:05pm
View
The code already works! only the matter of arrangement at command.commandText. Thanks for the help. I appreciate it!
arave0521
20-Oct-13 16:49pm
View
Here is the project file that I am stuck
https://www.dropbox.com/s/c8z58opqorplom6/DynamicSimulator_v2.zip
arave0521
20-Oct-13 16:45pm
View
The database has being populated. I had checked it in Mysql workbench. When I run the modified code, it says that error in SQL syntax near '.Metabolites WHERE MetaboliteID IN ('met1', 'met2');
arave0521
20-Oct-13 16:35pm
View
the code still have proble with sql command. I pretty sure the query was right.
arave0521
20-Oct-13 16:20pm
View
If I'm using ExecuteReader, can I insert and edit data during runtime? Can you show it based on my code. I still don't get it. Thanks
arave0521
20-Oct-13 11:04am
View
hai, i don't get it where should i put the break points. i thought if we put
<pre> break; </pre>
it resulting error in if else statements
arave0521
19-Oct-13 9:06am
View
yes, it goes to the condition but the datagridview only shows plain grey panel
arave0521
19-Oct-13 2:08am
View
I had update the problem of code. thanks for reminding
arave0521
19-Oct-13 1:52am
View
Dear Sergey Alexandrovich,
I had update the code. Thanks for the reminding.
arave0521
19-Oct-13 1:27am
View
Hai, this is my code. I wrote it by referring from the tutorial and make some modification.
arave0521
19-Oct-13 1:25am
View
hai,
I tried insert
dbMetName.DataBind();
it says there is no extension of it in datagridview.
arave0521
13-Oct-13 8:53am
View
Ohh, my mistake. Suppose the both of the
command.ExecuteNonQuery();
conn.Close();
are in comments mode.
But still the database is not selected.
i try modified using add parameter value the error said that fatal error occur. here is the code
try
{
MySqlCommand command = conn.CreateCommand();
conn.Open();
command.CommandText = "DROP DATABASE IF EXISTS " + database;
command.ExecuteNonQuery();
command.CommandText = "CREATE DATABASE " + database;
command.ExecuteNonQuery();
conn.Close();
conn.ConnectionString = connStr;
MySqlCommand comm = conn.CreateCommand();
conn.Open();
comm.CommandText = "CREATE TABLE @schema.Metabolites(MetaboliteID VARCHAR(10) NOT NULL, Metabolite_Name VARCHAR(45) NULL, ReactionTime INT NULL, PRIMARY KEY (MetaboliteID)";
comm.Parameters.AddWithValue("@schema", database);
comm.ExecuteNonQuery();
this.Hide();
form2.Show();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
conn.Close();
arave0521
13-Oct-13 8:36am
View
private void btnNew_Click(object sender, EventArgs e)
{
SchemaName schemaForm = new SchemaName();
frmMetCon form2 = new frmMetCon();
if (schemaForm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
string connStr = "datasource=localhost;port=3306;username=root;password=root;";
string database = schemaForm.getData();
MySqlConnection conn = new MySqlConnection(connStr);
try
{
MySqlCommand command = conn.CreateCommand();
conn.Open();
command.CommandText = "DROP DATABASE IF EXISTS " + database;
command.ExecuteNonQuery();
command.CommandText = "CREATE DATABASE " + database;
command.ExecuteNonQuery();
conn.Close();
command.ExecuteNonQuery();
conn.Close();
conn.ConnectionString = connStr;
MySqlCommand comm = conn.CreateCommand();
conn.Open();
comm.CommandText = "CREATE TABLE Metabolites(MetaboliteID VARCHAR(10) NOT NULL, Metabolite_Name VARCHAR(45) NULL, ReactionTime INT NULL, PRIMARY KEY (MetaboliteID)";
comm.ExecuteNonQuery();
this.Hide();
form2.Show();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
conn.Close();
}
}
}
Here is the code I try modified based on you given example. the problem i'm facing now is the conn is not open. i insert open connection but still the same error appear. Any advise?
arave0521
12-Oct-13 14:27pm
View
there is an error on con.connsectionstring=Connectionstring;// this will contain the same server information but database information is the new one,
arave0521
12-Oct-13 13:51pm
View
I don't get it. do you mind showing example?
arave0521
12-Oct-13 13:40pm
View
I tried but still got error. The error said that no database selected. if I create
try
{
MySqlCommand command = conn.CreateCommand();
conn.Open();
command.CommandText = "DROP DATABASE IF EXISTS " + schemaForm.getData();
command.ExecuteNonQuery();
command.CommandText = "CREATE DATABASE " + schemaForm.getData();
command.ExecuteNonQuery();
command.Parameters.AddWithValue("@schema",database);
command.CommandText = "CREATE TABLE @schema.Metabolites(MetaboliteID VARCHAR(10) NOT NULL, Metabolite_Name VARCHAR(45) NULL, ReactionTime INT NULL, PRIMARY KEY (MetaboliteID)";
command.ExecuteNonQuery();
this.Hide();
form2.Show();
}
there is still an error
arave0521
12-Oct-13 13:28pm
View
There is nothing wrong with the connection. It works fine. The proble I'm facing is the command of creating table based on user defined the database name
command.CommandText = "CREATE TABLE" +schemaForm.getData()+ ".Metabolites(MetaboliteID VARCHAR(10) NOT NULL, Metabolite_Name VARCHAR(45) NULL, ReactionTime INT NULL, PRIMARY KEY (MetaboliteID)";
arave0521
12-Oct-13 12:55pm
View
winforms
arave0521
11-Oct-13 9:51am
View
thanks for the tips once again =)
arave0521
11-Oct-13 9:21am
View
Schema is the right word. The only problem is I'm using a ExecuteReader(). I just solved it by using ExecuteNonQuery()
arave0521
11-Oct-13 9:20am
View
Thanks for the help. I'm using ExecuteNonQuery(). And it is working. Thanks. May I know the differences of ExecuteNonQuery() and ExecuteReader in your perspective point of view. I thought both are quite the same
arave0521
11-Oct-13 9:19am
View
Deleted
Thanks for the help. I'm using ExecuteNonQuery(). And it is working. Thanks. May I know the differences of ExecuteNonQuery() and ExecuteReader in your perspective point of view. I thought both are quite the same
arave0521
11-Oct-13 0:00am
View
May I know how to set it as property. Quite new in c#.net
arave0521
10-Oct-13 23:59pm
View
In form2.
FORM2(schemaName)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace DynamicSimulator_v2
{
public partial class SchemaName : Form
{
private string data;
public SchemaName()
{
InitializeComponent();
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.Hide();
}
private void btnOK_Click(object sender, EventArgs e)
{
data=txtDB.Text;
this.Hide();
}
public string getData()
{
return data;
}
}
}
FORM1(frmMain)
namespace DynamicSimulator_v2
{
public partial class frmMain : Form
{
public frmMain()
{
InitializeComponent();
}
private void btnExit_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void btnNew_Click(object sender, EventArgs e)
{
string data = frm.getData(); //get data from Form2
SchemaName schemaForm = new SchemaName();
if (schemaForm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
MessageBox.Show(data);
string connStr = "datasource=localhost;port=3306;username=root;password=root;";
MySqlConnection conn = new MySqlConnection(connStr);
try
{
conn.Open();
MySqlCommand cmdDatabase = new MySqlCommand("CREATE SCHEMA @schema; ", conn);
cmdDatabase.Parameters.AddWithValue("@schema",data);
MySqlDataReader myReader;
myReader = cmdDatabase.ExecuteReader();
myReader.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
conn.Close();
}
}
}
}
arave0521
10-Oct-13 23:58pm
View
FORM2(schemaName)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace DynamicSimulator_v2
{
public partial class SchemaName : Form
{
private string data;
public SchemaName()
{
InitializeComponent();
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.Hide();
}
private void btnOK_Click(object sender, EventArgs e)
{
data=txtDB.Text;
this.Hide();
}
public string getData()
{
return data;
}
}
}
FORM1(frmMain)
namespace DynamicSimulator_v2
{
public partial class frmMain : Form
{
public frmMain()
{
InitializeComponent();
}
private void btnExit_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void btnNew_Click(object sender, EventArgs e)
{
string data = frm.getData(); //get data from Form2
SchemaName schemaForm = new SchemaName();
if (schemaForm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
MessageBox.Show(data);
string connStr = "datasource=localhost;port=3306;username=root;password=root;";
MySqlConnection conn = new MySqlConnection(connStr);
try
{
conn.Open();
MySqlCommand cmdDatabase = new MySqlCommand("CREATE SCHEMA @schema; ", conn);
cmdDatabase.Parameters.AddWithValue("@schema",data);
MySqlDataReader myReader;
myReader = cmdDatabase.ExecuteReader();
myReader.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
conn.Close();
}
}
}
}
arave0521
10-Oct-13 23:50pm
View
The value of schemaForm.getData()is user define value which is I'm not stated. the code.
Here is the code of schemaForm
public partial class SchemaName : Form
{
private string data;
public SchemaName()
{
InitializeComponent();
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.Hide();
}
private void btnOK_Click(object sender, EventArgs e)
{
data=txtDB.Text;
this.Hide();
}
public string getData()
{
return data;
}
}
The error given is that You have an error in your SQL syntax, check the manual that corresponds to your MYSQL server version for the right syntax to use near "user-defined-schemaName" at line 1
arave0521
10-Oct-13 23:05pm
View
parent form is Form1
arave0521
10-Oct-13 23:04pm
View
Thank you for your help. =)
arave0521
6-Mar-13 21:54pm
View
I'm quite new in using codeDom. im not really understand about it related to my problem.thanks
Show More