Sql Azure - Create Database Cheat Sheet



Cheat Sheet to create a database using SQL Azure

using System.Data
using System.Data.SqlClient

protected void Page_Load(object sender, EventArgs e)
//stoaxy9 -unique server that is generated automatically for your account. Make trusted connection to false. 
    {
string sConn ="Server=tcp:stoaxy9.database.windows.net;
Database=SyntaxHelpDB;User ID=Hima;
'Always make trusted connection to false	 Password=password;Trusted_Connection=False";
SqlConnection objConn = new SqlConnection(sConn);
objConn.Open();
string sSQL = "CREATE TABLE SyntaxHelpTestTable 
( FirstName varchar(50) NOT NULL, LastName varchar(50) NULL, 
CONSTRAINT PK_TestTable PRIMARY KEY (FirstName) )";
        SqlCommand objCmd = new SqlCommand(sSQL, objConn);
        objCmd.CommandType = System.Data.CommandType.Text;
        objCmd.ExecuteNonQuery();
        objConn.Close();
      }

Share |

 Cant find the page you are looking for?
 Help us to improve by adding the content that you are looking for.
 Leave a feedback
 We look forward to hear your comments and feedback.