Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have created database name Notes.Table name tbNotes. Column names are NotesID(int),
Notes(Varchar), Client(Varchar),Date(DateTime),Category(Varchar).

Here is my Code for webservices....

C#
[WebMethod]
public int AddNotes(int NotesID, string Notes,string Client, string Date, string Category)
{

string strConn="Data Source=#####; Initial Catalog=Notes;uid=sa; pwd=####;";
SqlConnection cnn = new SqlConnection(strConn);
cnn.Open();

SqlCommand cmd = new SqlCommand();
cmd.Connection = cnn;

cmd.CommandText =

"insert into tbNotes(NotesID,Notes,Client,Data,Category)values (" + NotesID + ",'" + Notes + "','" + Client + "','" + Date + "', " + Category + ")";
int i = cmd.ExecuteNonQuery();
cnn.Close();

return i;
}

C#
private void button1_Click(object sender, EventArgs e)
{

if (txtnotesid.Text == "" || txtnotes.Text == "" || txtclient.Text == "" || category.Text == "")
{
MessageBox.Show("Please Enter The Details");
}

else
{
notesapp.WebService1 obj = new notesapp.WebService1();
}
Posted
Updated 7-Dec-12 22:12pm
v3
Comments
[no name] 8-Dec-12 3:44am    
and your problem is........?????????
Ritesh Zaveri 8-Dec-12 3:53am    
after adding details in form and then click on save button, my details should be stored in database using web services method
[no name] 8-Dec-12 4:02am    
Okay, so where's your Save Button code ???
Ritesh Zaveri 8-Dec-12 4:11am    
Save Button Code is in window form file...

private void button1_Click(object sender, EventArgs e)
{

if (txtnotesid.Text == "" || txtnotes.Text == "" || txtclient.Text == "" || category.Text == "")
{
MessageBox.Show("Please Enter The Details");
}

else
{
notesapp.WebService1 obj = new notesapp.WebService1();
}
Ritesh Zaveri 8-Dec-12 4:30am    
Thanks...:)

1 solution

C#
private void button1_Click(object sender, EventArgs e)
{

if (txtnotesid.Text == "" || txtnotes.Text == "" || txtclient.Text == "" || category.Text == "")
{
MessageBox.Show("Please Enter The Details");
}

else
{
notesapp.WebService1 obj = new notesapp.WebService1();
int n = obj.AddNotes(txtnotesid.Text,txtnotes.Text,txtclient.Text,category.Text);
StatuLabel.Text = n.ToString();
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900