Hola tengo un problema con mi codigo, me dice que una palabra clabe no es permitida:
Palabra clave no admitida: 'data source(localhost);initial catalog'.
Mi codigo
Código:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
}
protected void Button1_Click1(object sender, EventArgs e)
{
String cadenaCon;
String cadenaSql;
SqlConnection cn;
SqlCommand cmd;
cadenaCon = "Data Source(localhost);";
cadenaCon += "Initial Catalog=usuarios;";
cadenaCon += "Integrated Security=SSPI";
cadenaSql = "INSERT INTO infousers";
cadenaSql += "VALUES('" + TextBox1.Text + "',";
cadenaSql += "'" + TextBox2.Text + "')";
cn = new SqlConnection(cadenaCon);
try
{
cn.Open();
cmd = new SqlCommand(cadenaSql, cn);
cmd.ExecuteNonQuery();
Label2.Text = "El usuario se dio de alta correctamente";
}
catch (Exception ex)
{
Label2.Text = "Error al registrar" + ex.Message;
}
finally
{
cn.Close();
}
}
}
AYUDA