C# - Use For Doing Local MySQL Testing?
Apr 4, 2011I want to test MySQL with ASP .NET locally. However, I do not want to host a local server. How would I simulate a local MySQL server using files or something similar?
View 4 RepliesI want to test MySQL with ASP .NET locally. However, I do not want to host a local server. How would I simulate a local MySQL server using files or something similar?
View 4 RepliesI do not want to do my development based on an emulator, so I want to be able to have my phone (Android), to connect to my local PC to make sure what I am developing comes out the way I want it to.
Issue #1 - I need to be able to connect to my network, not internet, I can't have my PC internet facing, this limits me from opening my PC to the internet.
Issue #2 - No WiFi allowed at my work, security issues.
Issue #3 - I can't publish this to a internet facing site, since the procedure to get it to one, take a few days each publish and will put my development to a crawl.
What I'm looking for, is a way to get my phone to connect to my local PC, maybe via USB/Bluetooth but have access to my local IIS.
I am testing with windows authentication and a local express DB. My DB has users and roles tables. Following link explains this concept:[URL]
Code:
[HandleError]
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
[Authorize(Roles = "Managers")]
public ActionResult CompanySecrets()
{
return View();
}
[Authorize(Users="redmond\swalther")]
public ActionResult StephenSecrets()
{
return View();
}
}
Above roles are coming from NTLM. Is there a way where i can map roles in my DB table so that these are then available to me like User.IsInRoles("Admin") etc?
I have VWD 2010 Express installed. While developing I would like my co-workers to test the application (the parts that are "finished"). When I click "View in browser" for some web form of my application or "Start debugging" the app is shown in my browser at:
http://localhost:3424/Default.aspx
My IP on local network is 192.168.1.14. How can my co-workers access this page?
Note: I do not have IIS instaled (just ASP.NET Development Server).
When I use the following in a webmethod:
string mysqlsPath = Server.MapPath("applog.txt");
command.CommandText = "LOAD DATA LOCAL INFILE '" + mysqlsPath + "' INTO TABLE numbers FIELDS TERMINATED BY ',' LINES TERMINATED BY '
'";
command.ExecuteNonQuery();
connection.Close();
I get Error LOAD DATA LOCAL INFILE ---> Could not find file
'c:windowssystem32inetsrvinetpubwwwrootwebservicesapplog.txt'
When looking at this error i noticed that after "inet"its dropping the "" between the rest of the directories,what could be causing this and how can I fix it?
I'm busy working on an ASP.NET Web Application (3.5) and can't seem to connect to a MySQL DB. I first created the entire application using a WinForms template and everything works 100%, but as soon as I move the exact same code to the Web Application, I can't connect anymore. Here's the code:
Code:
public class DBC {
OdbcConnection connection;
public bool CreateConnection() {
try {
string connFormat = "Driver={MySQL ODBC 5.1 Driver};Server=[SERVER];Database=[DBNAME];User=[UID];Password=[PWD];";
connFormat = connFormat.Replace("[SERVER]", Properties.Settings.Default.DBServer);
[Code] .....
As soon as I try to create the new OdbcConnection instance, I get the error:
Code: ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
As noted this works in a WinForms app, and even more strange is that I don't even specify a DSN name...
All I could find from reading through forums all over the internet is suggestions of downgrading the MySQL ODBC driver version, which I'd really rather not...
I've found a Webmatrix help article that says MS Webmatrix "publishes the (SQL Server or MySQL) database by creating scripts that run in a database that has been created for you by your hosting provider." That is wonderful, except I can't get it to work when I'm trying to publish a MySQL database (backing wordpress) through FTP (my hosting provider does not support 'web deploy'). Again, no problem, since it is already documented that " FTP protocols cannot be used to publish MySQL database. " But this does not excuse Webmatrix from generating MySQL database install scripts for me. During the publishing step, no database install script is generated - at least that I can tell - and there is no manual option to create a database export / backup / install script.
In short, as Webmatrix goes, I'm dead in the water trying to get my database uploaded to my hosting provider. Does anyone know the trick to force Webmatrix to create the MySQL database install scripts on my local box? Once created, I can take-over the upload and install process.
Recently for a class to implement unit test for one of its private methods I used PrivateObject by creating private accessor instead of refelection, to which i received a code review comment as below
"My main concern with Private Object is the use of object[] in constructor. It replaces strong typing enforced by compiler with JavaScript-style run-time error detection.Consequently , personally, I would not recommend it."
Comments above confused me beacuse as per my understanding reflection also needs the object[] to invoke any method.
am working as a web developer in a company. I am not aware of anything related to testing. Our company is planning to buy some testing softwares. Presently we are working on ASP.NET. We will be working on PHP and JAVA in future. I need your help to find out the best but cost effective testing sofwares.on TFS and Visual Studio Testing tool.
View 2 Repliesi was just using mysql i installed mysql and mysql net connector. its installed successfully but unable tp add to references.
View 3 RepliesI'm currently building a .net web application that uses WCF web services to allow a Flex front end to access the database.
I'm in the process of setting up some unit/integration style testing on the web services and am trying to work out the best way to allow the tests to access and modify data in a separate test database.
Currently, the connection string in my unit test project points to my testing database, and the connection string in my web services project points to my development database. However, as I am using Linq it appears that when I call the web service methods from my test class, it uses the development database connection string. I have looked into creating mock objects or in-memory database but I believe the same issue would occur.
Is there a way to get this to work, or is my entire idea about what I want incorrect, in which case is there a better way to set this up?
Why does a very simple script which inserts 26,000 records into a mysql database (myisam, no transactions) take 13 seconds in the php implementation, and then 35-50 seconds using mono+mysql connector? I thought asp.net was faster than php? Could the problem be the mono mysql connector is "platform independent", so the performance just stinks? or does asp.net suffer more overhead than php when it comes to executing each query? Aren't there any native linux binaries for mysql connector for mono that may be faster?
View 1 RepliesI have used ASD.NET code using SQL Database for Transaction operation successfully. By changing the Database Code to interface with MYSQL an Error occurs. If I remove the Transaction Code from within the the application, it works OK by displaying the MYSQL data (Read Only) in the layout of the application. I am using Mysql Essential-4.1.22-win32 and MYSQL Connector ODBC-3.51.2. My objective is to EDIT the MYSQL Data.
View 8 RepliesMy code is to update a record if it already exists in database else insert as a new record. My code is as follows:
protected void Button3_Click(object sender, EventArgs e)
{
OdbcConnection MyConnection = new OdbcConnection("Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=testcase;User=root;Password=root;Option=3;");
MyConnection.Open();
String MyString = "select fil_no,orderdate from temp_save where fil_no=? and orderdate=?";
OdbcCommand MyCmd = new OdbcCommand(MyString, MyConnection);
MyCmd.Parameters.AddWithValue("", HiddenField4.Value);
MyCmd.Parameters.AddWithValue("", TextBox3.Text);
using (OdbcDataReader MyReader4 = MyCmd.ExecuteReader())
{
//**
if (MyReader4.Read())
{
String MyString1 = "UPDATE temp_save SET order=? where fil_no=? AND orderdate=?";
OdbcCommand MyCmd1 = new OdbcCommand(MyString1, MyConnection);
MyCmd1.Parameters.AddWithValue("", Editor1.Content.ToString());
MyCmd1.Parameters.AddWithValue("", HiddenField1.Value);
MyCmd1.Parameters.AddWithValue("", TextBox3.Text);
MyCmd1.ExecuteNonQuery();
}
else
{
// set the SQL string
String strSQL = "INSERT INTO temp_save (fil_no,order,orderdate) " +
"VALUES (?,?,?)";
// Create the Command and set its properties
OdbcCommand objCmd = new OdbcCommand(strSQL, MyConnection);
objCmd.Parameters.AddWithValue("", HiddenField4.Value);
objCmd.Parameters.AddWithValue("", Editor1.Content.ToString());
objCmd.Parameters.AddWithValue("", TextBox3.Text);
// execute the command
objCmd.ExecuteNonQuery();
}
}
}
I am getting the error as: ERROR [42000] [MySQL][ODBC 3.51 Driver][mysqld-5.1.51-community]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order,orderdate) VALUES ('04050040272009',' &' at line 1
The datatype for fields in table temp_save are:
fil_no-->INT(15)( to store a 15 digit number)
order-->LONGTEXT(to store contents from HTMLEditor(ajax control))
orderdate-->DATE(to store date)
I am trying to insert html pages to MySQL with my Asp.NET project but i am getting error; You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'de Osman patlaması', '', '<div style="text-align: center"> <img src="/i' at line 1
How can i fix that problem my server side code is;
MySqlConnection myCon = new MySqlConnection();
myCon.ConnectionString = ConfigurationManager.ConnectionStrings["MySQLConnectionString"].ConnectionString;
MySqlCommand cmd = new MySqlCommand();
cmd.CommandType = CommandType.Text;
string query = @"INSERT INTO `test`.`posts` (`id`, `author`, `title`, `description`, `content`, `ispublished`, `iscommentsenabled`, `pubDate`, `lastModified`, `raters`, `rating`, `slug`, `tags`, `categories`) VALUES (NULL, '{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}', '{12}')";
query = String.Format(query, p.author, p.title, p.description, p.content, p.ispublished, p.iscommentsenabled, p.pubDate, p.lastModified, p.raters, p.rating, p.slug, p.tags, p.categories);
cmd.CommandText = query;
cmd.Connection = myCon;
cmd.Connection.Open();
cmd.ExecuteNonQuery();
cmd.Connection.Close();..............
When I run the application using the Web Developer it works fine. However when I run it using local IIS I get the following error:
The resource class for this page was not found. check if the resource file exists and try again. Description: An unhandled exception occurred during the execution of the current web request. review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The resource class for this page was not found. heck if the resource file exists and try again.
Source Error:
Line 81: private void PopulateLanguageList()
Line 82: {
Line 83: DropDownListLanguage.Items[0].Text = (string)HttpContext.GetLocalResourceObject(
Line 84: "Default.aspx", SelectLanguage, Thread.CurrentThread.CurrentCulture);
Line 85: }
Stack Trace:
[InvalidOperationException: The resource class for this page was not found. Please check if the resource file exists and try again.]
System.Web.Compilation.LocalResXResourceProvider.CreateResourceManager() +4038050
System.Web.Compilation.BaseResXResourceProvider.EnsureResourceManager() +23
System.Web.Compilation.BaseResXResourceProvider.GetObject(String resourceKey, CultureInfo culture) +24
System.Web.Compilation.ResourceExpressionBuilder.GetResourceObject(IResourceProvider resourceProvider, String resourceKey, CultureInfo culture, Type objType, String propName) +32
System.Web.HttpContext.GetLocalResourceObject(String virtualPath, String resourceKey, CultureInfo culture) +56
APPortal.Login.PopulateLanguageList() in c:inetpubwwwrootAPPortalDefault.aspx.cs:83
APPortal.Login.Page_Load(Object sender, EventArgs e) in c:inetpubwwwrootAPPortalDefault.aspx.cs:20
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +25
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +42
System.Web.UI.Control.OnLoad(EventArgs e) +132
System.Web.UI.Control.LoadRecursive() +66
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2428
I created a website using VS2010. When I run the website using built-in web server, everything works fine. The website recognizes javascript and aurigma uploader. When I publish the website to local folder and tried to access using IIS 5.1 on local pc,
the java scipt files did not work. I was getting yellow triangle sign at the bottom of the page indicating the object is expected. I tried to look online but i could not find any answer. I have included jquery and javascript file in the header section of master
There is a hyperlink to a local file...for instance....C:/text.txt. This is not possible, because ASP.net does not allow links to local files. But, links to files on network drives such as W:/test.txt are working ok. how does the browser know which drive letter is local,and which is networked? How does it know that C: is local or D: is local etc, and that W: is a network drive?
View 1 RepliesHow do I get the smtp server address for the local machine? I want to my email address on a windows form and have the user send me an email and I need to be able to get their smtp server address programatically to do this. I tried this:
System.Net.Mail.
SmtpClient smtpc =
new
SmtpClient("127.0.0.1");
smtpc.Send(email);
It caused an exception.
I have been looking at the unit testing topic and honestly I have never yet seen it in a live application.
Im a little foggy on the subject....
A simple example is if I am populating a listbox with data, I would know through debugging if the data is being populated and if it wasnt it would probably be easy to figure out why. Futhermore I couldnt possibly put it in production if it wasnt work so, why would I need to do a unit test? I dont see the point of it.
In MVC, the unit testing is primarily surrounding the controllers. The Model is rarely tested, and the View not at all. What is the consensus on this?
View 13 RepliesI'm using the Moq framework to do my unit testing. I'm following some really useful instructions outlined here to mock the httpcontext, specifically for the purposes of testing the url referrer:[URL]
Everything seems to compile fine, however when running the test I get the following error:
System.Web.HttpException: Invalid use
of SimpleWorkerRequest constructor.
Application path cannot be overridden
in this context. Please use
SimpleWorkerRequest constructor that
does not override the application
path..
When analyzing I find the error seems to be thrown at the following line:
var wr = new SimpleWorkerRequest("", "", "", "", writer); I'm not sure what to make of this. What is the SimpleWorkerRequest and how does it work in creating the HttpContext in Moq?? Why is my use of it invalid according to the debugger??
UPDATE: Here is the complete method I use taken from the website above
public static HttpContextBase FakeHttpContext()
{
var httpContext = new Mock<HttpContextBase>();
var request = new Mock<HttpRequestBase>();
var response = new Mock<HttpResponseBase>();
var session = new Mock<HttpSessionStateBase>();
var server = new Mock<HttpServerUtilityBase>();
var cookies = new HttpCookieCollection();
httpContext.Setup(x => x.Server).Returns(server.Object);
httpContext.Setup(x => x.Session).Returns(session.Object);
httpContext.Setup(x => x.Request).Returns(request.Object);
httpContext.Setup(x => x.Response).Returns(response.Object);
response.Setup(x => x.Cookies).Returns(cookies);
httpContext.SetupGet(x => x.Request.Url).Returns(new Uri("http://www.csuci.edu"));
httpContext.SetupGet(x => x.Request.UrlReferrer).Returns(new Uri("http://www.csuci.edu"));
//var writer = new StringWriter();
//var wr = new SimpleWorkerRequest("", "", "", "", writer);
//HttpContext.Current = new HttpContext(wr);
return httpContext.Object;
}
I commented out the problem lines, that seemed to fix it, but I'm still not sure what those lines were supposed to do and why they were causing error.
I know red-gate's ANTS Performance Profiler but it works with source code. I have an ASP.NET web application that is deployed on a remote server. I'm going to test its performance while it is working on the server.
My main goal is to detect what method of what class is slow and then is a bottleneck. Is there a way or a tool?
I use visual studio 2005 and now my team wants me to try my hand at some testing frameworks for asp.net websites.I'm completely new to testing. I want to know what kind of automated testing can I do.Can I test my business logic,Can I test my UI.I just started using NUnit and I am getting a hang of it. For Web UI testing I've tried Nunit asp.Somewhere I found about Selenium, which of this is better.Also is there an add-in to test Javascript code with NUnit.Is there an better alternative to NUnit.
View 1 RepliesI created a new ASP.NET MVC application and the accompanying unit tests that can be generated automatically. I created a new Controller method and tried to wire up a test. The test failed, and I tried to step through the test code to find out the state of certain variables. The breakpoint showed as being set, but it never was hit.
I did a Google search on this, and there are many other people wondering the same thing - why doesn't this work? The answers have been sketchy at best. The most proliferant seems to be that the unit tests are run in the production configuration instead of the debug configuration, and so several steps are required to get breakpoints to work. Seriously? This is something I would expect to be enabled by default. What good is test code you can't step through? Why create a set of unit tests that require you to jump through several hoops to get this very basic feature running? NUnit (and I suppose others) don't have this issue.
how to get the breakpoints to work were completely different than all the others, and I'd like to know if anyone has an idea of how to enable debugging of the unit tests that are included in Visual Studio 2008.