473,404 Members | 2,174 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

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 1783
Hi,

"Paul" <pa********@hotmail.com> wrote in message
news:ca**************************@posting.google.c om...
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
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...
0
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...
23
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...
2
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...
8
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...
1
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...
4
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...
4
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...
1
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.