TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Joe Wilson
NA
7.8k
417.6k
What is my program problem when it connect to database?
Jun 26 2014 4:24 AM
my code:
class Connection
{
public static string connectionString;
public DataTable ShowData(string s1)
{
OleDbConnection CN = new OleDbConnection();
CN.ConnectionString = connectionString;
CN.Open();
OleDbCommand CMT = new OleDbCommand(s1, CN);
OleDbDataReader da = CMT.ExecuteReader();
DataTable DT = new DataTable();
DT.Load(da);
CN.Close();
return DT;
}
public void SetData(string s2)
{
OleDbConnection CN = new OleDbConnection();
CN.ConnectionString = connectionString;
CN.Open();
OleDbCommand cmd = new OleDbCommand(s2, CN);
cmd.ExecuteNonQuery();
CN.Close();
}
public bool IsExist(string s3)
{
OleDbConnection CN = new OleDbConnection();
CN.ConnectionString = connectionString;
CN.Open();
OleDbCommand CMD = new OleDbCommand(s3, CN);
OleDbDataReader DR = CMD.ExecuteReader();
if (DR.Read())
return true;
return false;
CN.Close();
}
}
}
When i debug my program the below error appear how can i solve it?
Error:
An unhandled exception of type 'System.InvalidOperationException' occurred in System.Data.dll
Additional information: The ConnectionString property has not been initialized.
Reply
Answers (
1
)
How can i change background color of Windows form?
How to create a text box by click a button in Windows Form?