473,762 Members | 7,330 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Please help: Creating a table in a sql server database

Hi,

I wish to be able to add tables to a sql server database at runtime
from my asp.net application. As well as creating fields I also wish to
be able to create indexes on selected fields and to assign user
permissions. (I need to assign permissions to the table object as I
will be using sp_executesql or exec to execute a string).

I'm thinking there are 3 possible ways to do this:

1. Create the table entirely using ADO.NET
2. Create a template table in sql server, copy the table and rename it
using ADO.NET by either calling a stored procedure or directly using
ADO.NET.
3. Calling a stored procedure that contains all the SQL necesary to
create the table, indexes and permissions.

I have read in a posting on a newsgroup that you cannot use ADO.NET
methods directly to create objects in a database meaning method 1 is
out. Is this correct?

I'm not sure of the SQL that would enable me to copy the structure of
the template table. I've read about the SELECT INTO but that does not
recreate indexes and presumably permissions? If that is so how would I
go about getting a reference to the new table from within my app to
create them - or would I better off using method 3.

If I use the method 3 will I be able to execute the stored procedure
from within my asp.net application? Is it only a matter of calling the
stored procedure from within my app using the credentials of a user
with administrative rights in my connection and making sure that the
appropriate permissions have been assigned in my database?

Thanks

Paul
Nov 18 '05 #1
1 1809
Hi,

"Paul" <pa********@hot mail.com> wrote in message
news:ca******** *************** ***@posting.goo gle.com...
Hi,

I wish to be able to add tables to a sql server database at runtime
from my asp.net application. As well as creating fields I also wish to
be able to create indexes on selected fields and to assign user
permissions. (I need to assign permissions to the table object as I
will be using sp_executesql or exec to execute a string).

I'm thinking there are 3 possible ways to do this:

1. Create the table entirely using ADO.NET
2. Create a template table in sql server, copy the table and rename it
using ADO.NET by either calling a stored procedure or directly using
ADO.NET.
3. Calling a stored procedure that contains all the SQL necesary to
create the table, indexes and permissions.

I have read in a posting on a newsgroup that you cannot use ADO.NET
methods directly to create objects in a database meaning method 1 is
out. Is this correct?
Yes. You might use ADOX though.
I'm not sure of the SQL that would enable me to copy the structure of
the template table. I've read about the SELECT INTO but that does not
recreate indexes and presumably permissions? If that is so how would I
go about getting a reference to the new table from within my app to
create them - or would I better off using method 3.
Yes, method 3 would be fine. Or, you can execute the same body of stored
procedure by invoking (the same) sql commands from the code.
If I use the method 3 will I be able to execute the stored procedure
from within my asp.net application? Is it only a matter of calling the
stored procedure from within my app using the credentials of a user
with administrative rights in my connection and making sure that the
appropriate permissions have been assigned in my database?


Yes, certainly.

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com
www.rthand.com
Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
17760
by: Amanda | last post by:
From a guy in Microsoft newsgroups: | In *comp.databases.ibm-db2* there are always IBM guys | from the Toronto labs on line.Post with the | -for the love of god please help- | line and I'm sure you'll get their attention. | Their usually very good:) So here's my transplanted post ==========================================
0
2401
by: Teddy | last post by:
hi everyone: i'm a college student and creating a simple database for the language lab on campus. the data table is already in ACCESS. what i need to do is to create a web page so that users can type in a keyword and search for the item they need. the table has about 10 fields, and the searching should go through all fields. suppose the ACCESS database is put into school's server, how do i make a page from which the user input can be...
23
3282
by: Jason | last post by:
Hi, I was wondering if any could point me to an example or give me ideas on how to dynamically create a form based on a database table? So, I would have a table designed to tell my application to create certain textboxes, labels, and combo boxes? Any ideas would be appreciated. Thanks
2
2910
by: Chad | last post by:
I have a problem that I am desperate to understand. It involves dynamically adding controls to a Table control that is built as a result of performing a database query. I am not looking to avoid the problem by avoiding the table control or resorting to databound controls that better manage state for me. I hope to understand how to solve the problem by using the Table web control and sticking to the approach of building the table at run...
8
2041
by: David | last post by:
Hi, Could someone please xplain how to add a field to an existing SQL table in VB.Net I have added the field in the Server Explorer and it shows up when I reload the program but I cannot access the field from within my program. Is there something I need to refresh or do I need to recreate he Dataapdtors
1
1928
by: RSH | last post by:
Im trying to create a stored procedure of the following code. I want to set it so that I have to send the first 4 variables (@DB, @BackUpFile,@TestDB,@RestoreFile). I am having trouble when i try to save it...SQL Server wants me to decalre the variables. How would I go about making this a stored procedure correctly? Here is the code: USE master GO
4
2430
by: Tarun Mistry | last post by:
Hi all, I have posted this in both the c# and asp.net groups as it applies to both (apologies if it breaks some group rules). I am making a web app in asp.net using c#. This is the first fully OO application I will be making, also my first .NET application, so im looking for any help and guidance. Ok, my problems are todo with object and database abstraction, what should i do.
4
2215
by: Brad Isaacs | last post by:
I am working with ASP.NET 2.0 and using an SQL Server 2000 database. I am using Visual Studio 2005 and developing on my Local machine. I am working with Login controls ASP.Configuration, I wanted to move my work and needed to place it on the server. Using VS 2005 , went to BUILD -Publish Web Site Checked the box for :: Alow this precompiled site to be updatable.
1
2773
by: DarkGiank | last post by:
Hi, im new to csharp and im trying to create a class that can change the application database without no rewriting all connection code... but cause some reason it is not working... it tells me that im not creating the object but im doing it,,, please help im a newbie to c# using System; using System.Collections.Generic; using System.Text; using System.Data; using System.Data.SQLite; using MySql.Data; using MySql.Data.MySqlClient; using...
0
9378
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10137
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9989
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9812
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6640
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5268
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3510
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2788
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.