C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » Visual Studio »

Runtime Create Database and Table


Posted Date: 30 Jun 2009    Resource Type: Code Snippets    Category: Visual Studio
Author: R.Jaya kumar (JK)Member Level: Diamond    
Rating: 1 out of 5Points: 4



how to create database and table in runtime simple code below try this

First Step


Create Proc CrDb
as
create Database Test7
Create Table Welcome12
(id int,
StName varchar(20))


if you delete procedure try this

Create Proc DropDb
Drop Database Test7



Behind Code .aspx file


Imports System.Data
Imports System.Data.Sql
Imports System.Data.SqlClient
Partial Class _Default
Inherits System.Web.UI.Page
Dim sqlcon As SqlConnection
Dim sqlcmd As SqlCommand
Dim Sqlado As SqlDataAdapter
Dim result As Boolean
Protected Sub bt1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles bt1.Click
result = Execute("Exec Crdb")
End Sub
Public Sub New()
sqlcon = New SqlConnection
sqlcon.ConnectionString = "data source=(local);Initial Catalog=Test;Integrated Security=true;"
sqlcon.Open()
End Sub
Public Function Execute(ByVal strq As String) As Boolean
Dim sqlcmd As New SqlCommand(strq, sqlcon)
sqlcmd.ExecuteNonQuery()
End Function
End Class


html Code ur file like this


< html xmlns="http://www.w3.org/1999/xhtml" >
< head runat="server">
< title>Untitled Page< /title>
< /head>
< body>
< form id="form1" runat="server">
< asp:Button ID="bt1" runat ="server" Text ="Click" />
< /form>
< /body>
< /html>





Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Runtime Create Database and Table  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: .NET Windows Forms - Find all information about Computer
Previous Resource: Multi Database Connectivity Different BackEnd New one
Return to Discussion Resource Index
Post New Resource
Category: Visual Studio


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use