有关代码的信息.................... [英] info about code....................

查看:74
本文介绍了有关代码的信息....................的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public void ConnectDataBaseToInsert(string Query)
   {
       con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\omar\Documents\Visual Studio 2005\WebSites\Project2\App_Data\Database.mdf;Integrated Security=True;User Instance=True");

       cmd.CommandText = Query; //what does this line do?
       cmd.Connection = con; //what does this line do?
       da = new SqlDataAdapter(cmd); //what does this line do?
       con.Open();
       cmd.ExecuteNonQuery();
       con.Close();
   }


1)什么是cmd.commandtext?
2)什么是Sqldataadapter(cmd)


1)what is cmd.commandtext?
2)What is Sqldataadapter(cmd)

推荐答案

cmd.CommandText = Query;这行做什么?

它告诉SqlCommand对象Command文本是一个sql查询(与存储过程名称相对)

cmd.Connection = con;这行是做什么的?

这会将SqlCommand对象设置为使用指定的SqlConnection

da = new SqlDataAdapter(cmd);这行做什么?

这将使用SqlCommand对象实例化SqlDataAdapter,并允许您访问返回的数据.

----

严重的是,如果您如此懒惰,以至于无法通过一些细微的搜索来找到这些答案,那么您作为程序员的职业将是短暂的.
cmd.CommandText = Query;what this line do?

It tells the SqlCommand object that the Command text is a sql query (as opposed to a stored procedure name)

cmd.Connection = con;what this line do?

This sets the SqlCommand object to use the specified SqlConnection

da = new SqlDataAdapter(cmd);what this line do?

This instantiates a SqlDataAdapter with the SqlCommand object, and allows you to access the returned data.

----

Seriously, if you''re so freakin'' lazy that you can''t do some minor googling to find these answers, your career as a programmer will be very short-lived.


如果您使用的是Visual Studio IDE

为什么不右键单击代码,然后使用转到定义",则可以在其中查看每个属性或方法的所有详细信息.

希望这会有所帮助:)
If you are using Visual Studio IDE

why don''t you right click on the code, and use Go to Definition, there you can view all the details of each and every property or method.

hope this helps :)


这篇关于有关代码的信息....................的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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