Ver Mensaje Individual
  #7 (permalink)  
Antiguo 15/04/2011, 12:43
Avatar de Jesua
Jesua
 
Fecha de Ingreso: septiembre-2008
Ubicación: Guatemala, Guatemala
Mensajes: 29
Antigüedad: 15 años, 7 meses
Puntos: 0
Respuesta: Error Coneccion SQL Server C# .net

gracias Ka0stj.

practicamente tengo esto .... pero tengo la duda de donde colocarlo...

Código PHP:
<&#37;@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<
html xmlns="http://www.w3.org/1999/xhtml">
<
head runat="server">
    <
title></title>
</
head>
<
body>
    <
appSettings>
&
#160;   <add key="ConnectionString" value="data source = BJESUA-PC/SQLEXPRESS; initial catalog = IPC2; user id = bjesua-PC/bjesua;/>
&#160;   </appSettings>
    
<form id="form1" runat="server">
    <
div>
        <
asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <
br />
        <
asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
        <
br />
        <
asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
        <
br />
        <
asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
        <
br />
        <
asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>
        <
br />
        <
asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
   
    </
div>
    </
form>
</
body>
</
html
y mi codigo

Código PHP:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Data.Sql;
using System.Data.SqlClient;



public 
partial class _Default System.Web.UI.Page 
{
    protected 
void Page_Load(object senderEventArgs e)
    {
    
    }

    protected 
void Button1_Click(object senderEventArgs e)
    {

        
string connString Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["ConnectionString"]);
                      
        
SqlConnection objConn;
        
objConn = new SqlConnection(connString);
            &
#160;
            
try
            {
&
#160;                objConn.Open();
            
&#160;    
&#160;               // Tus rutinas
            
&#160;  SqlCommand myCommand = new SqlCommand("insert into usuario values ('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "','" + TextBox5.Text + "')", objConn);
                
myCommand.ExecuteNonQuery();
&
#160;               objConn.Close();
               
           
}

            catch (
Exception ex)
            {
                throw 
ex;
            }
    }


gracias!.exitos.