Jump to content
Xtreme .Net Talk

trying to save data from webForm via a web service.need help


Recommended Posts

Posted

im sending data from a web form to a web service that saves the data to a database. here is a simplified version of the web form code that creates a new row with the inputted data and passes it to the web service method InsertData.

 

DataSet dataset = new System.Data.DataSet();
		DataTable table = new DataTable("Feedback");

		table.Columns.Add("Name");
		table.Columns.Add("Phone");
		table.Columns.Add("comment");

		DataRow row = table.NewRow();
		row["Name"] = this.TextBox1.Text;
		row["Phone"] = this.TextBox2.Text;
		row["comment"] = this.TextBox3.Text;

		table.Rows.Add(row);
		localhost.Service1 service = new Feedback.localhost.Service1();
		dataset.Tables.Add("Feedback");

here is a basic version of the web service code that is supposed to insert the data into a table:

 

first i open the connection like this:

		connString = "server=fintanspc; uid=fintan; pwd=nokia3210;database=Test";
		conn = new SqlConnection(connString);
		adapter = new SqlDataAdapter("select*from Feedback",connString);
		dataSet = new DataSet();
		adapter.Fill(dataSet,"Feedback");
		dataTable = this.dataSet.Tables[0];

then i try to append the data using this method :

	public int InsertData(DataSet data)
	{
		this.OpenConn();
		DataRow row;
		row = dataTable.NewRow();
		row["Name"] = data.Tables["Feedback"].Rows[0].;
		row["Phone"] = data.Tables["Phone"].Rows[0].ItemArray[1];
		row["comment"] = data.Tables["comment"].Rows[0].ItemArray[2];
		dataTable.Rows.Add(row);

		
		adapter.Update(dataSet,"Feedback");
		dataSet.AcceptChanges();
	}

this does not work, and i have tried many variants of this but i cant get it done. can anyone show me what im doing wrong

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...