by
0
7
1,212
2
Top 1% !
Popular
Famous
Easy-to-find
Specified
Refined
OpenSource
Popularity: 22839th place

Published on:

InputName0connString
InputType0String
LanguageCSharp
LicenseMIT_X11
MethodNameCreateTable
OSWindows
OutputTypeBoolean

CreateTable: If there's no table [dbo].[Products] in DbDataIsolationLevel, create           the table; or recreate it.

<summary>
If there's no table [dbo].[Products] in DbDataIsolationLevel, create
the table; or recreate it.
</summary>
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/287718/CreateTable--If-there-s-no-table--dbo---?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
using System; using System.Data.SqlClient; /// <summary> /// If there's no table [dbo].[Products] in DbDataIsolationLevel, create /// the table; or recreate it. /// </summary> public static Boolean CreateTable(String connString) { using (SqlConnection conn = new SqlConnection(connString)) { String cmdText = @"Use DbDataIsolationLevel if Object_ID('[dbo].[Products]') is not null drop table [dbo].[Products] Create Table [dbo].[Products] ( [ProductId] int IDENTITY(1,1) primary key, [ProductName] NVarchar(100) not null, [Quantity] int null, [Price] money null )"; using (SqlCommand command = new SqlCommand(cmdText, conn)) { conn.Open(); command.ExecuteNonQuery(); } } return InsertRows(connString); }
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus