using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Drawing;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string s = System.Configuration.ConfigurationManager.ConnectionStrings["Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Documents and Settings\\Hitech\\Desktop\\JTS.mdb"].ConnectionString;
SqlConnection con = new SqlConnection(s);
SqlCommand cmd = new SqlCommand("select * from JTS where barcode='" + TextBox1.Text + "'", con);
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("@Id", TextBox1.Text);
cmd.Connection = con;
con.Open();
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
TextBox2.Text = dr["CNAME"].ToString();
TextBox3.Text = dr["MNAME"].ToString();
}
dr.Close();
con.Close();
}
}
2 Replies - 296 Views - Last Post: 20 December 2012 - 06:12 PM
#1
my task is to make editing interface for access using asp.net(c#)
Posted 20 December 2012 - 03:41 AM
i have 3 textboxes in one is to enter bar code and a button(submit) on submitting bar code the minfo and finfo should appear on other textboxes so that they can be edited
Replies To: my task is to make editing interface for access using asp.net(c#)
#2
Re: my task is to make editing interface for access using asp.net(c#)
Posted 20 December 2012 - 06:47 AM
What's the problem you're having? Are you getting any errors? You say this should happen when a button is clicked so why is the code in the page load instead of a button click event?
#3
Re: my task is to make editing interface for access using asp.net(c#)
Posted 20 December 2012 - 06:12 PM
You need to supply the name of the element in config file. The connection string needs to be a valid address and not the one you used to develop on your local machine.
System.Configuration.ConfigurationManager.ConnectionStrings("name of element in config").ConnectionString
'returns the con string stored in the config file
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote




|