在Visual Studio中使用数据源向导 [英] Using datasource wizard in visual studio

查看:491
本文介绍了在Visual Studio中使用数据源向导的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Visual Studio 2010中提供的数据源配置向导将数据源添加到我的应用程序中.几天前,我添加了一个没有问题的表.现在,当我尝试添加表时,出现以下错误;

无法检索表或视图的架构信息.

有谁知道解决此错误的方法,或者失败了,没有简单的代码向数据库添加行.谢谢您的帮助.

I am trying to add a data source to my application using the data source configuration wizard provided in visual studio 2010. I added one table with no problems a few days ago. Now when I try to add a table I get the following error;

Could not retrieve schema information for table or view.

Does anyone know a way to solve this error or, failing that, simple code to add a row to a database. Any help would be appreciated thanks.

推荐答案

将行插入表中:
SqlCommand cmd = new SqlCommand("INSERT INTO myTable (myColumn1, myColumn2) VALUES @MC1, @MC2", con);
cmd.Parameters.AddWithValue("@MC1", 1);
cmd.Parameters.AddWithValue("@MC2", 2);
cmd.ExecuteNonQuery();

(这假定您已打开并准备好连接"con",并且您已经使用SQL而不是mySQL,SQLCE,Access,Oracle等)

(This presumes you have a connection "con" open and ready, and that you are using SQL rather than mySQL, SQLCE, Access, Oracle, ...)


这篇关于在Visual Studio中使用数据源向导的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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