如何使用class,Object,properties将数据插入到asp.net的sql server中 [英] How to insert data into sql server in asp.net using class,Object,properties

查看:61
本文介绍了如何使用class,Object,properties将数据插入到asp.net的sql server中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



任何人都可以使用c#在asp.net中给我一个示例程序代码,用于通过类,属性,对象将数据插入到sql server中。



在内联命令中使用对象

Hi,
Can anyone give me a example program code in asp.net using c# for insert data into sql server by using class,properties,Object.

"To use object in inline command"

推荐答案

检查这个 SQL Server + C#:SELECT,INSERT,DELETE和UPDATE查询和存储过程 [ ^ ]



和Tomas表示你应该检查谷歌。您需要付出一些努力才能搜索现有的解决方案以及它们是否适合您。



我们随时为您提供帮助并获得帮助。
check this SQL Server + C#: SELECT, INSERT, DELETE and UPDATE Queries and Stored Procedures[^]

and as Tomas indicated you should check on the Google. You need to put some efforts to get search the existing solution and if they dont work for you.

We are here to help you and get help.


我想您正在寻找这种格式..





clsInsert.cs

I think You are Looking For this Format..


clsInsert.cs
public class clsInsert
{
    public static int actInsert(sqlInsert obj)
    {
        int intRes = 0;
        try
        {
            //insert code here..
            if ("success")
            {
                intRes = 1;
            }
            else
            {
                intRes = 0;
            }
        }
        catch (Exception e1)
        {
            intRes = -1;
        }
        return intRes;
    }
}
public class sqlInsert
{
    public string UserName { get; set; }
    public string Password { get; set; }
}





Insert.aspx





Insert.aspx

protected void btnInsert_Click(object sender, EventArgs e)
{
    sqlInsert clsObj = new sqlInsert();
    clsObj.UserName = txtUsername.Text;
    clsObj.Password = txtPassword.Text;
    int intres=clsInsert.actInsert(clsObj);
    if (intres == 1)
    {
        Response.Write("Success!");
    }
    else
    {
        Response.Write("Failed");
    }
}


转到此链接

http://msdn.microsoft.com/en-us/library/aa581776.aspx [ ^ ]



you会得到你想要的东西



一个建议

使用论坛代码项目那些真正需要帮助的东西会帮助你在你的开发Carear



我在这里粘贴第一个链接,我做了google
go to this link
http://msdn.microsoft.com/en-us/library/aa581776.aspx[^]

you will get what you want

one suggestion
use forum like code project for those thing that really need help that will help you a in your development carear

As I paste here first link that I have got doing google


这篇关于如何使用class,Object,properties将数据插入到asp.net的sql server中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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