使用.net C#插入表值Db [英] insert table values Db using .net C#

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

问题描述

hi

我想要通过.net(C#)在数据库工作台中插入,创建,更新,删除表的源代码,
example

hi

i want source code for insert,create,update,delete Table in DataBase workbench through .net (C#),
example

推荐答案

尝试这些文章

ADO.Net教程
CP文章
Try these articles

ADO.Net tutorial
CP Article


< pre lang ="c#"> ; SqlCommand cmd = new SqlCommand(插入技术注册值(""+ txttechid.Text +"''," + txtname.Text +'',""+ txtloginName.Text +"'',' '"+ txtpwd.Text +"''," + txtphoneno.Text +'',''" + txtemail.Text +'',""+ txteducation.Text +"'',''"+ txtExperience.Text +'',""+ txtaddress.Text +"''," + txtCountry.Text +'',""+ txtpincode.Text +"''," + Doj +'')",(SqlConnection)Application.Get("con")));
cmd.ExecuteNonQuery();
lblmessage.Text =提交成功";</pre>


其余更新删除u分析此代码并编写ok



问候,

Anilkumar.D
<pre lang="c#">SqlCommand cmd = new SqlCommand("insert into technicalregistration values(''" + txttechid.Text + "'',''" + txtname.Text + "'',''" + txtloginName.Text + "'',''" + txtpwd.Text + "'',''" + txtphoneno.Text + "'',''" + txtemail.Text + "'',''" + txteducation.Text + "'',''" + txtExperience.Text + "'',''" + txtaddress.Text + "'',''" + txtCountry.Text + "'',''" + txtpincode.Text + "'',''" + Doj + "'')", (SqlConnection)Application.Get("con"));
cmd.ExecuteNonQuery();
lblmessage.Text = "Submited Successfully";</pre>


Remainning Update Delete u analize this code and write ok



Regards,

Anilkumar.D




您应该在Google上查看有关此的一些文章,但这是一个简单的示例:

Hi,

You should check out some articles on Google about this, but here''s a quick example:

SqlConnection connection = new SqlConnection(connectionString);
SqlCommand cmd = new SqlCommand("SELECT Table1.Field1 FROM [dbo].[Table1] WHERE Table1.Field2 = @Field2", connection); //@Field2 is a parameter

//This is where you set the @Field2 parameter value.
cmd.Parameters.Add("@Field2", SqlDbType.NVarChar).Value = your_criteria;

cmd.CommandType = CommandType.Text

SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
    ...
    ...
    ...
}



这样,您就可以免费获得Sql Injection Attacks,并且拥有一个优雅"的解决方案.

希望对您有帮助...



This way, you are Sql Injection Attacks free, and you have an ''elegant'' solution.

Hope it helps...


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

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