问题将Gridview连接到Sql [英] Question connect Gridview to Sql

查看:63
本文介绍了问题将Gridview连接到Sql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi Team Code Project



我有一个问题,如何连接数据库(SQL服务器)来更新注册表。



例如,我完成了代码asp到Windows Forms,在我的DB中有一行名为IDTipoApoyoEconomico,信息为NULL



主要问题,我想在最终用户选择页面中的复选框并最后按下发送按钮时。自动获取DB的信息并更新IDTipoApoyoEconomico列的注册表。



一般信息是如何在我的ASP中连接数据库,我是这种语言的ASP和SQL服务器的新手。



Code DB





UPDATE BeneficiarioControl

SET IDTipoApoyoEconomico ...

...







JuanFranciscoHernándezZavala

解决方案

嗨Juan,



这里是连接Sqlserver的步骤。



Web.Config

 <   connectionStrings  >  
< remove name = CON / >
< add name = CON < span class =code-attribute> providerName = System.Data.SqlClient connectionString = server = YourServerName; database = YourDBName; uid = YourUserID; password = YourPwd; / >
< / connectionStrings >



.cs

 静态 < span class =code-keyword> string  constr = ConfigurationManager.ConnectionString s [  CON]。ConnectionString.ToString(); 

SqlConnection con = new SqlConnection(constr);
SqlCommand cmd;
cmd = new SqlCommand( YourProcedureName ,con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue( @ QryId UPDATE);
cmd.Parameters.AddWithValue( @ Price,Param1);
cmd.Parameters.AddWithValue( @ Option,Param2);
if (CurrDate!= DateTime.MinValue)
{
cmd.Parameters.AddWithValue( @ CurrDate,Param3);
}
else
{
cmd.Parameters.AddWithValue( @ CurrDate,System.Data.SqlTypes.SqlDateTime.Null);
}
con.Open();
result = cmd.ExecuteScalar()。ToString();
cmd.Parameters.Clear();
cmd.Dispose();
con.Close();



如需更多连接字符串,请查看以下链接:http://www.connectionstrings.com/ [ ^


Hi Team Code Project

I have one question, how i can connect an database (SQL server) to update registry.

For example, I finish the code asp to Windows Forms, in my DB have row called "IDTipoApoyoEconomico" with information in "NULL"

The principal issue, I want when the finally user selection the checkbox in the page and last press button "send". Automatically the information got the DB and update the registrys of the column "IDTipoApoyoEconomico".

The general message is how connect DB in my ASP, Im new in this language ASP and SQL server.

Code DB


UPDATE BeneficiarioControl
SET IDTipoApoyoEconomico...
...



Juan Francisco Hernández Zavala

解决方案

Hi Juan,

Here the steps to connect with Sqlserver.

Web.Config

<connectionStrings>
    <remove name="CON"/>
    <add name="CON" providerName="System.Data.SqlClient" connectionString="server=YourServerName;database=YourDBName;uid=YourUserID;password=YourPwd;"/>
</connectionStrings>


.cs

static string constr = ConfigurationManager.ConnectionStrings["CON"].ConnectionString.ToString();

        SqlConnection con = new SqlConnection(constr);
        SqlCommand cmd;
        cmd = new SqlCommand("YourProcedureName", con);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.AddWithValue("@QryId", "UPDATE");
        cmd.Parameters.AddWithValue("@Price", Param1);
        cmd.Parameters.AddWithValue("@Option", Param2);
        if (CurrDate != DateTime.MinValue)
        {
            cmd.Parameters.AddWithValue("@CurrDate", Param3);
        }
        else
        {
            cmd.Parameters.AddWithValue("@CurrDate", System.Data.SqlTypes.SqlDateTime.Null);
        }
        con.Open();
        result = cmd.ExecuteScalar().ToString();
        cmd.Parameters.Clear();
        cmd.Dispose();
        con.Close();


For More Connections String, please check the following link: http://www.connectionstrings.com/[^]


这篇关于问题将Gridview连接到Sql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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