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
Goran Bibic
455
2.9k
198k
Select values from diferent db with same app C#
Sep 4 2018 12:26 PM
I have some simple app
Two database:
1) 2017 (table name partners(id, name))
2) 2018 (table name partners(id, name))
On Form 1 have username, password, button login and combo box.
On Form 2 empty partnerdatagrid
I need when in combobox chose value 2017 show data from database 2017 (table name partners(id, name)),
if choose value 2018 to show data from 2018 (table name partners(id, name))
Some help?
Combobox value are find on next way
InitializeComponent();
comboBox1.DataSource = GetDatabaseList();
public
List<
string
> GetDatabaseList()
{
List<
string
> list =
new
List<
string
>();
using
(SqlConnection con =
new
SqlConnection(cs))
{
con.Open();
// Set up a command with the given query and associate
// this with the current connection.
using
(SqlCommand cmd =
new
SqlCommand(
"SELECT name from sys.databases where name like '20%'"
, con))
{
using
(IDataReader dr = cmd.ExecuteReader())
{
while
(dr.Read())
{
list.Add(dr[0].ToString());
}
}
}
}
return
list;
}
Reply
Answers (
4
)
Open image from picturebox in windows photo viewer C#
Use value from combo box to another form c#