So first Assert I'm making sure cars that aren't 4WD exist in the database otherwise it wouldn't be a valid test.
Second Assert I'm making sure at least one was returned.
Third Assert I'm making sure that all the cars returned were in fact 4WD.
I know this isn't a good test because I'm using the same logic in the test as the function I'm testing. However this is the only way I can currently think of to do this.
I want to create a common unit test function to check all functions based on parameter
for e.g
[code]....
what logic should i write inside this method so that by passing a actual function in parameter methodname and then the common method should execute that function and should return the output.
i am using entity framework for all functions which has been created in my project and now i dont want to create a separate unit test function for each function.just one function should do the job based on different parameters...
using .NET 2.0 want to format datagrid , i am using DataGrid. i am saving data from textbox to database as formated text. now while retriving data from database i can see html format data i need to format : Example
<B> test my text </B> new test. want to show in dagagrid like test my text new test: and when i click on datagrid i want to see test my text new test this format not styling below code for data grid
When adding a stored procedure into the Entity Data Model I can select whether the procedure returns a scalar, a (new) complex type or one of the entity types I already defined.I mean assuming I have a view like this
CREATE VIEW FilteredFoos as SELECT Foo.* FROM Foo join ... WHERE ...(that is a view that implements some involved filtering, but returns all columns from one table) how do I add it to the project so that I can use the entity set, but get the Foo objects, not some new FilteredFoo objects.
var foos = myDB.FilteredFoos.Include("Bar").ToList(); foreach (Foo foo in foos) { ...
I was assigned a task on creating a web application that connects and display database information on a grid view. My supervisor suggested me to download .NET pet shop 4.0 to serve as a template for my project.As I only have limited basic knowledge on C# and HTML codings, the .NET pet shop 4.0 is too difficult and complex for me to understand. So I have a few questions:
Which functions are required to connect to the database? Which functions display information of the database? How do I change the categories of the .NET pet shop 4.0? If I want to add a grid view to display the records instead of listing informations of the products, where should I add the code and how will it roughly look like?
In my application, users fill out a form to submit a "Job Request" - once they submit the form it is stored as a new row in a table in the Sql database. Each "Job Request" that is submitted is given a "JobID" which is a number and also the primary key of the new row in the database (the number is generated by the database). Once the users hit the "submit" button, I'd like to return the value of the "JobID" (the primary key) so that the user can know what it is. How would I achieve this? In the future, I will have to expand the application so that the users would be able to edit an older "Job Request" and get a similar JobID number (so if before it was 1234, the new one would be 1234-1 or something like that), so this is not simply a matter of searching for the highest number in the primary key field in the table and returning that. I'm using Sql for my database and writing in VB.
Is there a way of selecting returned values from a call to an sql database in the code behind? For example assume that I used the following to select values from a table called Products;
SELECT Price, Qty, Numbersold FROM Products
How can I now get the returned values e.g. Price in the c# codebehind and display it in a textbox? I know that in the asp markup that I can use EVAL and Bind statements to do this for example I can do Eval("Price") but is there a way of getting any of the selected values (Price, Qty or Numbersold) in the codebehind?
I know that I can use three separate select statements and make three separate calls to return each value and then do something like the following
I am trying to create a search page, this allows the admin to search through the entries in the database by certain criteria, such as province (like state but diff country)
Here is the code I have so far. The problem is that I am not getting any errors. But I am also not getting any results. The page just posts back and returns to the blank search page. The GridView does not display any results.
here is my code as it stands:
Imports System.Data Imports System.Data.SqlClient Imports System.Web.Configuration Partial Class administration_Search Inherits System.Web.UI.Page Protected Sub ProvinceButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ProvinceButton.Click 'get the search string from text box Dim Search As String Search = ("%" & ProvinceButton.Text & "%") 'if the string has value then continue with search If Len(Trim(Search)) > 0 Then Dim con As String = WebConfigurationManager.ConnectionStrings("fubar").ToString() 'build sql string Dim s As String s = ("SELECT id, surname, name FROM orders WHERE province like @strSearch") 'declar connection Dim c As SqlConnection = New SqlConnection(con) 'add command Dim x As New SqlCommand(s, c) 'add parameter x.Parameters.AddWithValue("@strSearch", strSearch) c.Open() Dim r As SqlDataReader = x.ExecuteReader GV.DataSource = r GV.DataBind() c.Close() Else Province.Text = ("Please enter search terms") End If End Sub End Class
On the .aspx page I have a textbox (id: province) and a button (id:submit)
I have an entry from a database that has 500 characters. But when i display it i only want to return 200 charcters. How do I do that. I use Sql Server.
I need to somehow test if a table exists in a database. If it does not then I need to create the table. How can I test for existence of a table using SQL? It seems like some type of SQL logic is needed?
I have .sql database that I created in Visual Web Developer. I have uploaded the .sql file to the host company and they have successfully imported it. When I try to test the database on the server I am getting an error page (listed below). I have inserted a connection string in the web.config file (see below) and isnerted the relevant fields.
We have a web project that contain its business methods in a class library project called "Bll.dll" some methods of Bll.dll return List<> ... from a source - that i don't remember now - told that returning Collection<> is better than returning List<> Is it a valid ? Note that i don't make any process on values returned from BLL methods .. just view it in a web page
i have to do some message exchange with a 3rd party (in a website).When the client posts a page, i start the message exchange. When that doesn't succeed for some reason, i report this to the client by rendering the page with a message.On the background, in a separate thread, i start a process to send abort messages to the 3rd party. I can't do this while the user is waiting for the page to come back, because it might take a few minutes.But in a test project, the test ends when the message to the 3rd party is sent, and after the new thread is started. But it seems that the new thread also ends, when the test is done.
Is that normal behaviour?I do start the thread in a new class with a reference to 2 objects from the class which tries to send the message in the first place, may that be a problem?EDIT: it keeps running when the whole process is started in IIS
I am doing Automated coded ui testing in asp.net 2010 for web application. I am testing site and i need to know how can i create the test which will work with all browsers. Right now i created test in IE 8 but its not working in Firefox. So is there any way i can create one test and will work in all browser.
I'm trying to create a class, DataCommon, to contain all my SQL Data manipulation functions. I've created a Subroutine called Init that initializes a SQLDataAdapter:
[Code]....
From my other classes I am creating an instance of DataCommon, calling Init, and calling another subroutine in DataCommon that pulls data from SQL and loads the data into my dataset. This part is working great -- no problems at all. I'm loading three different Datatables in the Dataset with no issues.
At this point, I'll perform my various manipulations on the datatables -- add/delete/modify rows -- again with no problems. All of this is creating postbacks...and this is where my problem begins. After I've done all my manipulations to the data and am ready to update my SQL tables, I have to re-initialize my SQLDataAdapter. I thought I could do something like: [Code]....
But I get the error: Exception inserting Class. Thread was being aborted.
In my initial data load from SQL, each datatable is getting loaded from a single SQL table, so I was hoping to use the autogenerated Update/Insert/Delete statements by the SQLDataAdapter. As a test, as soon as I filled the dataset initially, I added a new row to one of the datatables and used the SQLDataAdapter.Update() method before a postback occurred, and it worked perfectly.
So, with all that being said, I guess my question is, how do I reconnect the table mappings between my SQLDataAdapter and dataset to autogenerate the updates after a postback occurs? I've tried researching this, but I get confused after reading about FillSchema vs TableMappings vs everything else I've read about.
I have been researching this issue for a couple of days and have found a lot written about it, but none of what I have found has fixed the problem I am having.
I work for a school system, and my principals are wanting to take a list of the staff members at their school and create staff lists for different activities they perform. I thought I would load the staff into Gridveiw1, and when they select a record have it move over into Gridview2 and "delete" from Gridview1.
I am loading my full staff into a datatable (SQL Server backend), and setting this datatable as my gridview1 datasource. At this point, it loads great, and cosmetically speaking sorts and pages fine. The problem occurs in the codebehind after a Sort or Page change has occurred -- when I select a record and move it over into Gridview2, it is moving the original record that was at that postion on Page 1 instead of the sorted or "new page" record.
So if the initial list comes in as:
Teacher 1 Teacher 2 Teacher 3
The sort button is hit so that the list now starts out like:
Teacher 7 Teacher 13 Teacher 5
If they select "Teacher 13" to be moved over after the sort, instead it is still moving over "Teacher 2" -- the initial teacher in that index before the sort.
The Gridview setup on my aspx page looks like this:
I have a search box on a web application that is to use a query I have built in Access to search through projects to find any that are related to the text entered in the search box.
The query in Access is just made up of parameters that use wildcards to search through all the fields. In Access the query works fine and returns the correct data but when I try and link this all up to a ListView in Visual Studio, the ListView just diplays the message "No data was returned"
Below is my page-behind code, hopefully you can see why it is not working but it looks like it should work to me.
I have a page where users can search by company name, the data list is pulled from an Excel spreadsheet hosted on the site. I'm seeing some strange results returned, for example:
In the company field say there are the following entries:
Anns Company Bernards Business Company B Dermots Domain Property Company
If I search for "Com" I get the following returns (correct):
Anns Company Company B Property Company
If I search for "Der" I get my "Sorry there are no matching results" message (Incorrect)
If I search for "Ann" I get the following returns (Correct):
Anns Company
And if I search for "e" I get the following returns (Correct):
Bernards Business Dermots Domain Property Company
It seems random as to why it doesn't return some values, I've tried moving rows around to see if that's the problem but it makes no difference. My range is set correctly in the spreadsheet.
When I debug the VB code behind, when I search for something that works correctly e.g. "Com" in the above example, once enter the value and click search Visual Studio begins steping into the code and shows me the contents of the variables however when I search for something that's not working e.g. "Der" and click search it immediatly returns the "Sorry there are no matching results" message and the code behind does not get steped into.