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
praveen maurya
NA
0
29.2k
Database not accessible
Apr 23 2020 4:22 AM
Hello There
I am just learning user Control in Visual Studio 2015. Everything was going fine but when i tried to access the database in user control file i am getting null error
the same connection string is working fine in winform but not working in usercontrol the error comming when I am trying to drag the user control page to my winform. the image of error is attached
my app.config code is written here
app.config
<?xml version=
"1.0"
encoding=
"utf-8"
?>
<configuration>
<configSections>
</configSections>
<connectionStrings>
<add name=
"CC"
connectionString=
"Data Source=DESKTOP-M5IBRH0\sqlexpress;Initial Catalog=RMS;Integrated Security=True"
providerName=
"System.Data.SqlClient"
/>
</connectionStrings>
<startup>
<supportedRuntime version=
"v4.0"
sku=
".NETFramework,Version=v4.5.2"
/>
</startup>
</configuration>
Code of User Control:
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Drawing;
using
System.Data;
using
System.Linq;
using
System.Text;
using
System.Threading.Tasks;
using
System.Windows.Forms;
using
System.Data.SqlClient;
using
System.Configuration;
namespace
usercontrol_with_sqlconnection
{
public
partial
class
user_A : UserControl
{
public
static
string
constring = ConfigurationManager.ConnectionStrings[
"CC"
].ConnectionString;
SqlConnection con =
new
SqlConnection(constring);
public
user_A()
{
InitializeComponent();
}
}
}
Reply
Answers (
3
)
Data migration in Dynamic CRM 365
Crystal Report Occur error while open form