help in c# web service
-
hi i am trying to make a simple web application using web services with c# web matrix i have get the data from html page and i can print it on my aspx page but i could not be able to pass my data to my web services in my web services i want to send my data in access database we i show you my code as under that i used ... this is my html code
First Name:
Last Name:
this is my aspx page code <%@ Page Language="C#" Debug=true %> void Page_Load(object src,EventArgs e) { String fn,ln; fn = Request.Form.Get("fname"); ln=Request.Form.Get("lname"); Response.Write("Your First Name is = " +"<b>" +fn +"</b>" +"<br>"); Response.Write("Your Last Name is = " +"<b>" +ln +"</b>" +"<br>"); } and this is my web services code <%@ WebService language="C#" Debug="True" class="my" %> using System; using System.Web.Services; using System.Xml.Serialization; public class my { [WebMethod] public void Add(string a, string b) { OleDbConnection objConnection = null; OleDbCommand objCmd = null; string strConnection, strSQL; strConnection = "Provider=Microsoft.Jet.OLEDB.4.0 ;Data Source="+Server.MapPath(".\\database\\t1.mdb"); // Create and open the connection object objConnection = new OleDbConnection(strConnection); objConnection.Open(); // Set the SQL string strSQL = "INSERT INTO sis (fname, lname) VALUES ( a , b)"; // Create the Command and set its properties objCmd = new OleDbCommand(strSQL, objConnection); // here our ionsert query will execute and insertour data in the database. objCmd.ExecuteNonQuery(); objConnection.Close(); } } Mazhar Hussain
-
hi i am trying to make a simple web application using web services with c# web matrix i have get the data from html page and i can print it on my aspx page but i could not be able to pass my data to my web services in my web services i want to send my data in access database we i show you my code as under that i used ... this is my html code
First Name:
Last Name:
this is my aspx page code <%@ Page Language="C#" Debug=true %> void Page_Load(object src,EventArgs e) { String fn,ln; fn = Request.Form.Get("fname"); ln=Request.Form.Get("lname"); Response.Write("Your First Name is = " +"<b>" +fn +"</b>" +"<br>"); Response.Write("Your Last Name is = " +"<b>" +ln +"</b>" +"<br>"); } and this is my web services code <%@ WebService language="C#" Debug="True" class="my" %> using System; using System.Web.Services; using System.Xml.Serialization; public class my { [WebMethod] public void Add(string a, string b) { OleDbConnection objConnection = null; OleDbCommand objCmd = null; string strConnection, strSQL; strConnection = "Provider=Microsoft.Jet.OLEDB.4.0 ;Data Source="+Server.MapPath(".\\database\\t1.mdb"); // Create and open the connection object objConnection = new OleDbConnection(strConnection); objConnection.Open(); // Set the SQL string strSQL = "INSERT INTO sis (fname, lname) VALUES ( a , b)"; // Create the Command and set its properties objCmd = new OleDbCommand(strSQL, objConnection); // here our ionsert query will execute and insertour data in the database. objCmd.ExecuteNonQuery(); objConnection.Close(); } } Mazhar Hussain
This belongs in the ASP.NET forum. This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles]