如何将数据添加到SQL表

如何将数据添加到SQL表

本文介绍了如何将数据添加到SQL表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

你好

我想将数据添加到sql表中.我创建了dbutilites名称类,所有的executequery executescaler等都在其中.我在那里做了一个连接字符串,并且还创建了commandobject.
现在我想知道如何在添加按钮单击事件中调用命令对象,以便可以将数据存储在sql表中.

我添加按钮的代码是:

Hello

I want to add a data into sql table. I have created dbutilites name class in which all executequery executescaler etc., are there. I have made a connection string there, and created commandobject also.
Now i want to know how to call command object in add button click event so that the data could be stored in sql table.

My code for add button is:

cmd.Parameters.Add("@Name", SqlDbType.VarChar).Value = txtName.Text.Trim(); ;
            cmd.Parameters.Add("@Description", SqlDbType.VarChar).Value = txtDesc.Text.Trim(); ;
            cmd.Parameters.Add("@Image", SqlDbType.VarChar).Value = txtImage.Text.Trim();
            cmd.Parameters.Add("@Active", SqlDbType.VarChar).Value = txtActive.Text.Trim();
            cmd.Parameters.Add("@CreatedBy", SqlDbType.VarChar).Value = txtCreatedBy.Text.Trim();
            cmd.Parameters.Add("@CreatedDate", SqlDbType.DateTime).Value = txtCreDate.Text.Trim();



            cmd.Connection = con;



请帮助我创建在dbutlites和command对象中的连接对象.
帮助



Plz help me to how to create a connection object which is in dbutlites and command object.
Help

推荐答案



这篇关于如何将数据添加到SQL表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 18:38