Thank you Alaric. I tried it and it works. Now I would like to switch to SQL SERVER 2005 instead of SQL Server Express. How should I change the connection string? Thanks, Hezi
hezi
Posts
-
SQL Server Express doesn't work -
SQL Server Express doesn't workI try to open the SQL Server Express database file "sample.mdf" but it doesn't work. Here is the code: -------------------------------------------------------------------------- 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.OleDb; using System.Data.SqlClient; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { //OleDb-ACCESS //-------------- //OleDbConnection con = new OleDbConnection(); //string comPath = Server.MapPath("~" + @"\") + @"app_Data\webTest.mdb"; //string coS = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + comPath; //SqlClient-SQL server express //------------------------------ System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection(); string comPath = Server.MapPath("~" + @"\") + @"app_Data\sample.mdf"; string coS = "Data Source=.\\SQLEXPRESS;AttachDbFilename=" + comPath + ";Integrated Security=True;User Instance=False;"; //OleDb-SQL server express //------------------------- //OleDbConnection con = new OleDbConnection(); //string comPath = Server.MapPath("~" + @"\") + @"app_Data\sample.mdf"; //string coS = "Provider=SQLOLEDB.1;" + "Data Source=" + comPath; con.ConnectionString = coS; con.Open(); } } -------------------------------------------------------------------------- 1. Code OleDb-ACCESS (commented) works OK. 2 . When I run the code in section: SqlClient-SQL Server express, I get error: Server Error in '/myWeb/trySqlServer' Application. -------------------------------------------------------------------------- CREATE DATABASE permission denied in database 'master'. An attempt to attach an auto-named database for file C:\MyPrograms\web\trySqlServer\app_Data\sample.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: CREATE DATABASE permission denied in database 'master'. An attempt to attach an auto-named database for file
-
onMouseOver handler does not get the argumentI have a matrix of checkboxes and I would like to get the id on which the mouse is over. I set the onMouseOver handler programmatically by the following C# code in the Page_Load procedure: checkBoxObject.Atributes.Add("onMouseOver","mouseOverHandler(this)"); The client's MouseOverHandler function (JavaScript) is: Function mouseOverHandler(this) { alert(document.getElementById(me.id)) } When I move the mouse over a checkbox I get an empty alert box. It seems that the function "mouseOverHandler " does not get the firing checkbox in the argument"me". The same code works correctly when I change the triggering event from "onMouseOver" to "onClick". 1. Why does it work with "onClick" and dose not work with "onMouseOver" 2. How can I make it to work with "onMouseOver" Thank you Hezi