如何从C#中的其他数据库表创建数据库表 [英] How to Create data base table from other database table in C#

查看:58
本文介绍了如何从C#中的其他数据库表创建数据库表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我正在使用c#和sql server 2005,我想从现有数据库中使用c#创建数据库...
但是我在代码中发现了一些错误,即

Hello everyone, Am working with c# and Sql server 2005 , I want to create a database using with c# from existing database ...
but i have find some error in my code, ie.

SqlConnection sqlcon = new SqlConnection("Data Source=.\\SQLEXPRESS;initial catalog=;Integrated Security=SSPI;User Instance=True");
sqlcon.Open();
SqlCommand sqlcmd = new SqlCommand("SELECT * INTO imgsoftware.dbo.ram4 FROM TBLADMIN", sqlcon);
sqlcmd.ExecuteNonQuery();
sqlcon.Close();



错误是:数据库"imgsoftware"不存在.但我有这个数据库


如果有人对这个问题有解决方案,请告诉我..

谢谢....



error is: Database ''imgsoftware'' does not exist. but i have this database


if someone have any solution of this problem tell me..

Thanx ....

推荐答案



http://www.functionx.com/csharp1/adonet/Lesson04.htm

希望该网址对您有所帮助.
Hi,

http://www.functionx.com/csharp1/adonet/Lesson04.htm

Hope this url is helpfull to you.


您好,

您需要为此执行CREATE TABLE .... AS查询.

检查链接.

您还需要指定数据库名称以及表名称.

希望对您有帮助,

谢谢
-Amit.
Hi,

You need to execute CREATE TABLE....AS query for that.

check this link.

you also need to specify your database name along with your table name.

hope it will help you,

thanks
-Amit.


创建表DatabaseName.schemaName.tableName
.............
......

例如.

创建表Test.dbo.Testing(id int)
Create table DatabaseName.schemaName.tableName
.............
...............

eg.

Create table Test.dbo.Testing(id int)


这篇关于如何从C#中的其他数据库表创建数据库表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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