Hey all,
I'm using Visual Studio 2008 proffessional with SQL2008 express. Using Visual C#, and Asp.net web application.
but i cannot establish the connection or to be more specific i dont know what the problem is.
i know the server is connected, tables established and everything. Here's my code, tell me what's wrong with it and how can i solve it. if there are any paths or any thing just tell me where can i get it from.
Thank you for the Help
CODE
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
namespace WebApplication1
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection sqlConnection1 = new SqlConnection();
SqlCommand sqlCommand1 = new SqlCommand();
sqlConnection1.ConnectionString = "Data Source=FADY-PC\\SQLEXPRESS";
sqlConnection1.Open();
sqlCommand1.ExecuteNonQuery();
sqlConnection1.Close();
}
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
String connstr = "Data Source=FADY-PC\\SQLEXPRESS";
SqlConnection tarek = new SqlConnection(connstr);
String query = "insert into patient(name,ssn)values('titoo',555)";
SqlCommand co = new SqlCommand(query, tarek);
tarek.Open();
co.ExecuteReader();
tarek.Close();
}
}
}
if any information is missing please tell me.