使用C#SQLServer2005的ASP.NET [英] Asp.net with c# sqlserver2005

查看:61
本文介绍了使用C#SQLServer2005的ASP.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

using System;
using System.Collections;
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.IO;
namespace photoshops
{
    public partial class WebForm2 : System.Web.UI.Page
    {
        SqlConnection conn = new SqlConnection();
        protected void Page_Load(object sender, EventArgs e)
        {
            conn.ConnectionString
              = @"Data Source=DEVI\SQLEXPRESS; Initial Catalog =cat; Integrated Security=SSPI";
            Load_GridData(); // call method below
        }
        void Load_GridData()
        {
            conn.Open(); // open the connection 
            SqlDataAdapter Sqa = new SqlDataAdapter("select * from tblphotosettings", conn);
            DataSet ds = new DataSet();
            Sqa.Fill(ds);  // fill the dataset 
            GridView1.DataSource = ds.Tables[0]; // give data to GridView
            conn.Close();
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            string strText = TextBox1.Text;
            SqlDataAdapter Sqa = new SqlDataAdapter("select * from tblphotosettings where BillNo= " + strText + "", conn);
        }
    }
}

我已经在客户账单号中输入了一个文本框,然后单击在gridview中显示图像客户记录的按钮....如何更改我的代码..因为我是初学者...您可以发布code

解决方案

1)在您的代码中添加一个按钮
2)在您的代码中添加一个文本框(用于帐单号)
3)在按钮的clcik事件处理程序上,编写一些代码以将帐单编号插入数据库中.


使用按钮单击事件
你可以这样写

字符串strText = textbox.text;

SqlDataAdapter Sqa = 新建 SqlDataAdapter("  + strText +  ",conn); 


using System;
using System.Collections;
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.IO;
namespace photoshops
{
    public partial class WebForm2 : System.Web.UI.Page
    {
        SqlConnection conn = new SqlConnection();
        protected void Page_Load(object sender, EventArgs e)
        {
            conn.ConnectionString
              = @"Data Source=DEVI\SQLEXPRESS; Initial Catalog =cat; Integrated Security=SSPI";
            Load_GridData(); // call method below
        }
        void Load_GridData()
        {
            conn.Open(); // open the connection 
            SqlDataAdapter Sqa = new SqlDataAdapter("select * from tblphotosettings", conn);
            DataSet ds = new DataSet();
            Sqa.Fill(ds);  // fill the dataset 
            GridView1.DataSource = ds.Tables[0]; // give data to GridView
            conn.Close();
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            string strText = TextBox1.Text;
            SqlDataAdapter Sqa = new SqlDataAdapter("select * from tblphotosettings where BillNo= " + strText + "", conn);
        }
    }
}

i have enter a textbox in customer bill number and then click the button display image customer record in a gridview.... How to change in my code.. because i am begineer... can you post the code

解决方案

1) Add a button to your code
2) Add a textbox to your code (for the bill number)
3) On the button''s clcik event handler, write some code to insert the bill no into your database.


use button click event
in that u can write like

string strText=textbox.text;

SqlDataAdapter Sqa = new SqlDataAdapter("select * from tblphotosettings where YourColumnName= "+strText+"", conn);


这篇关于使用C#SQLServer2005的ASP.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆