Click here to Skip to main content
15,919,479 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to create the database on database live server using asp.net coding with c# please help me.

String str;      
        //String CONN = "Data Source=ERP3\\SQLEXPRESS;Integrated Security=True;";
        String CONN = "server=Admin;uid=sa;pwd=sa;";
        SqlConnection myConn = new SqlConnection(CONN);

        //str = "CREATE DATABASE test ON PRIMARY " +
        //    "(NAME = MyDatabase_Data, " +
        //    "FILENAME = 'C:\\MyDatabase_Data.mdf', " +
        //    "SIZE = 2MB,  FILEGROWTH = 10%) " +
        //    "LOG ON (NAME = MyDatabase_Log, " +
        //    "FILENAME = 'C:\\MyDatabase_Data.ldf', " +
        //    "SIZE = 1MB, " +
        //    "MAXSIZE = 5MB, " +
        //    "FILEGROWTH = 10%)";

        str = "CREATE DATABASE testHgtech ";

        SqlCommand myCommand = new SqlCommand(str, myConn);
        try
        {
            myConn.Open();
            myCommand.ExecuteNonQuery();
            //MessageBox.Show("DataBase is Created Successfully", "MyProgram", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        catch (System.Exception ex)
        {
            //MessageBox.Show(ex.ToString(), "MyProgram", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        finally
        {
            if (myConn.State == ConnectionState.Open)
            {
                myConn.Close();
            }
        }

    }






String CONN = "server=Admin;uid=sa;pwd=sa;";

the above code i am using for connentivity with local server it is working the same code for live server it is not working




I am using above code to create the database on live server but it is working on local server but not working on live server please help me.


plz help me
Posted
Updated 10-Feb-11 0:14am
v6
Comments
Monjurul Habib 10-Feb-11 9:08am    
check your connection string.

1 solution

String CONN = "server=Admin;uid=sa;pwd=sa;";

Are you sure this is the live server?
It doesn't look much like it, but I could be wrong...

Try connecting to a database you know is live, rather than local, and check that. Use the connection string to connect to your real, live server.

Are you sure you want to put test databases on your live production server? Does the DB admin know?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900