2 Replies - 486 Views - Last Post: 20 December 2012 - 06:12 PM Rate Topic: -----

#1 maheshkumar1228  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 20-December 12

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
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();
  }
}


Is This A Good Question/Topic? 0
  • +

Replies To: my task is to make editing interface for access using asp.net(c#)

#2 Nakor  Icon User is offline

  • Professional Lurker
  • member icon

Reputation: 441
  • View blog
  • Posts: 1,488
  • Joined: 28-April 09

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?
Was This Post Helpful? 0
  • +
  • -

#3 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1043
  • View blog
  • Posts: 4,057
  • Joined: 02-July 08

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

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1