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
Sofari Agali
1.5k
276
26.3k
Saving data in localDB
Oct 2 2020 9:06 AM
Hi!
I am facing a problem saving data in a local sql server 2008 database, in fact when I save everything is fine but as soon as I consult the database data there is nothing in it, someone could one help me please, here are my codes
Ma connexion string
class
connexion
{
public
static
string
getconnexion()
{
return
"Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\\Database.mdf;Integrated Security=True"
;
}
}
Class To Add Client:
{
SqlConnection con =
new
SqlConnection(connexion.getconnexion());
con.Open();
SqlCommand cmd1 =
new
SqlCommand(
"Insert into client(num_passport,nom,adresse,phone) values(@num_passport,@nom,@adresse,@phone)"
, con);
// cmd1.CommandType = System.Data.CommandType.StoredProcedure;
cmd1.Parameters.AddWithValue(
"@num_passport"
, num_passport);
cmd1.Parameters.AddWithValue(
"@nom"
, nom);
cmd1.Parameters.AddWithValue(
"@adresse"
, adresse);
cmd1.Parameters.AddWithValue(
"@phone"
, phone);
cmd1.ExecuteNonQuery();
Button Add event:
private
void
button1_Click(
object
sender, EventArgs e)
{
SaisieClient st =
new
SaisieClient();
st.Num_passport = idclt.Text;
st.Nom = clt.Text;
st.Adresse = adres.Text;
st.Phone = Int32.Parse(phone.Text).ToString();
st.Saisie();
Reply
Answers (
5
)
Can I use Console.ReadLine () inside object initialiser
Eliminates duplicate values from combo box