表单加载过程中的sql语句. [英] sql statement during form load..

查看:98
本文介绍了表单加载过程中的sql语句.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

strSQL =选择*来自条件在哪里的人="损坏"

然后我想在datagrid中显示它

使用此代码...

Stock_InDataGridView.DataSource = strSQL


我将该代码放入表单加载中,但没有显示,我在datagrid中可以看到为什么?

IM使用vb.net

strSQL = "SELECT * FROM Persons WHERE Condition =''Damage''"

then I want to display that in the datagrid

using this codes...

Stock_InDataGridView.DataSource = strSQL


I put that code in the form load but there is no display I can see in the datagrid why is that?

IM using vb.net

推荐答案

您是否建立了到数据库的连接?
Did you set up a connection to the database?


您正在分配字符串因为数据源和DataGridView都不知道如何处理它,所以它什么也不做.您将必须对数据库实际执行内联sql,检索数据集并将其绑定到网格.查找ADO.Net,特别是Connection,Command和DataAdapter类.不乏示例.
You''re assigning a string as the datasource and the DataGridView has not a clue what to do with it so it does nothing. You''ll have to actually execute the inline sql against the database, retrieve the dataset and bind that to the grid. Lookup ADO.Net, specifically the Connection, Command and DataAdapter classes. No shortage of examples.


您能给出示例的片段代码
can you give fragment code of example


这篇关于表单加载过程中的sql语句.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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