User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 402,906 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,123 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 2425 | Replies: 0
Reply
Join Date: Feb 2007
Posts: 7
Reputation: shikha.ch is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
shikha.ch shikha.ch is offline Offline
Newbie Poster

Help Create Table on SqlServer Through Asp.net coding

  #1  
Feb 15th, 2007
Anyone can help me as soon as possible.
I want to create table on my database. i tried Following code


Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim ConStr As String = "Data Source=Urjit6;Initial Catalog=MyDB;Integrated Security=True"
Dim MyCon As New SqlConnection(ConStr)
Dim SqlCom As New SqlCommand

Dim server As New Server(New ServerConnection(MyCon))
'Create object for database
Dim db As Database = server.Databases("MyDB")

'Create Table
Dim newTab As New Table(db, "NewTab")

'Add Columns in table
Dim idCol As New Column(newTab, "ID")
idCol.DataType = DataType.Int
idCol.Nullable = False
idCol.Identity = True
idCol.IdentitySeed = 1
idCol.IdentityIncrement = 1

Dim nameCol As New Column(newTab, "Name")
nameCol.DataType = DataType.VarChar(20)
nameCol.Nullable = False

newTab.Columns.Add(idCol)
newTab.Columns.Add(nameCol)
l1.Text="Table is Created"
newTab.Create()

and I got error


Server Error in '/asp/DataCon' Application.
--------------------------------------------------------------------------------

Property DefaultSchema is not available for Database '[MyDB]'. This property may not exist for this object, or may not be retrievable due to insufficient access rights.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: Microsoft.SqlServer.Management.Smo.PropertyCannotB eRetrievedException: Property DefaultSchema is not available for Database '[MyDB]'. This property may not exist for this object, or may not be retrievable due to insufficient access rights.

Source Error:


Line 24:
Line 25: 'Create Table
Line 26: Dim newTab As New Table(db, "NewTab")
Line 27:
Line 28: 'Add Columns in table



I have granted all permission of my database[MyDB] except connect.

what can I do for create table.
AddThis Social Bookmark Button
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb ASP.NET Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 3:33 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC