Jump to content

Recommended Posts

Posted (edited)

Boa noite tenho este código para inserir dados numa tabela e tenho que criar um ficheiro XML dos dados inseridos, não tenho problemas em inserir dados na tabela o meu problema é criar o ficheiro,

o código que tenho é :

con = new System.Data.SqlClient.SqlConnection();

con.ConnectionString = @"Data Source = MAQUINA0\SQLEXPESS;Initial Catalog=Database;Integrated Security=True";

con.Open();

try

{

SqlCommand command = con.CreateCommand();

command.CommandText = "INSERT INTO Receitas VALUES (" + textBox1.Text + ",'" + textBox2.Text + "', '" + textBox3.Text + "', '" + textBox4.Text + "')";

command.CommandType = CommandType.Text;

SqlDataReader reader = command.ExecuteReader();

reader.Close();

}

catch (Exception er)

{

MessageBox.Show(er.ToString(), "Erro de ligação");

}

Edited by gregurs

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.