1
Answer

eror in creation atable by using c#.net

sasa sasa

sasa sasa

16y
1.6k
1

while creation atable in sql server db i have the following eror

this is my code

try

{

string str="server=(local);database=test;integrated security = sspi ";

SqlConnection sc=new SqlConnection();

sc.ConnectionString=str;

SqlCommand smd=new SqlCommand();

smd.CommandText="create table " + textBox1 .Text + "(dd int not null , ss nvarchar(10)) ";

smd.Connection=sc;

sc.Open();

string x= smd.ExecuteNonQuery().ToString();

if(x!=null )

{

MessageBox.Show("1");

}

}

catch (Exception ex)

{

MessageBox.Show(ex.Message);

}

the error is the following

object reference not set to an instance object

please help me

Answers (1)