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
146
27.1k
How create A .exe file with SQL database and C# winform
Apr 27 2018 10:12 AM
HI there
I am working on a simple inventory project. I have used Visual Studio 2010 with C# cod and SQL Server 2008 for my project. my project is going to be finished but at the mean time i want to run the project on my collage PC but the collage PC is neither having Visual Studio and nor SQL server so i have created a setup file using visual studio installer. all was looking good. i install that setup file on Collage PC but when i tried to fetch the database the problem Starts. the software is not getting the database. here are my connection strings please check if i have to modify something.
this code is in my app.config file
<connectionStrings>
<add name=
"const"
connectionString=
"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Data.mdf;Integrated Security=True;User Instance=True"
providerName=
"System.Data.SqlClient"
/>
</connectionStrings>
and below code i have used in form
SqlConnection con =
new
SqlConnection(ConfigurationManager.ConnectionStrings[
"const"
].ConnectionString);
so the total form code is like this
public
partial
class
Form1 : Form
{
SqlConnection con =
new
SqlConnection(ConfigurationManager.ConnectionStrings[
"const"
].ConnectionString);
public
Form1()
{
InitializeComponent();
}
private
void
Login_Click(
object
sender, EventArgs e)
{
SqlDataAdapter sda =
new
SqlDataAdapter(
"Select Count(*) From Login where Username='"
+ username.Text +
"' and Password='"
+ password.Text +
"'"
, con);
DataTable dt =
new
DataTable();
sda.Fill(dt);
if
(dt.Rows[0][0].ToString() ==
"1"
)
{
this
.Hide();
Main ss =
new
Main();
ss.Show();
}
else
{
MessageBox.Show(
"please check Username and Password"
);
}
}
}
this is for login page cade..
please suggest need urgent help.
Reply
Answers (
4
)
how to convert project
Insert,Update, Delete Opearions in DB With React and MySQL