looping through a database to show information within divs - html

I am just starting out in ASP.NET with previous experience in C++ and was wondering if you can help me out/point me in the right direction here.
I know how to link an Access database to visual studio's web forms however when showing the data I have found the tables to be very ugly so wanted to populate classes with the data.
In my "product details" database are; product name, price, description, rating, cost etc.
Using this information from the database I understand that my code should attempt to connect to the database server then attempt to access the specified database schema.
By giving the database any table name I hoped to return an array of all rows with all data inside it, possibly within a function called selectingData? As it loops through each row, it stores the data as an associative array which is then saved as a new array element.
I could then apply some styling...
<div style="float:left; width:50%;"> ...logic of code... </div>
<div style="clear:both;"></div>

You should use Sql Server Express 2008 or 2012, might as well use 2012. Download and install, make sure to include Sql Server Management Studio with your installation package install. You can choose server only but you want the Sql Server Management Studio tool included in your install as well.
Sql Server Management Studio will easily import your Access database and make a Sql Database of it. Right click your localhost server after you install in Sql Server Management Studio and click Import and follow wizard options, there is a source type setting for Microsoft Access database.
From here you want to use Entity Framework 5 or 6 via Visual Studio 2012 or 2013. Visual Studio 2012 or 2013 Web Express are always free and the best IDE ever. You can generate a model of your imported access database. Just create a new ASP.NET Website (go with MVC) and then right click the project and select Add -> Add New Menu Item -> EF5.x or EF 6.x DbContext Generator. This will give you the functionality you need via Linq to query tables, get result sets, manipulate those result sets and bind them to your display HTML.
You might as well do things the right way since you are getting into ASP.NET. This path is a treat and easy to learn but you will have a day or two of a learning curve ahead of you.

Related

SQL Server 2008 Sharepoint list

I am trying to link a sharepoint list to another using sql server database. The ideal would be for this is to a live link so that when data in the sharepoint list is updated, the data in the sql server database is also updated. The reason that I need to do this is that I have an ASP page which will query the SQL database and display the results on a web page.
Any guidance would be much appreciated
Thanks in advance
SidJ
PS : I have done this in access before using the External Data tab ->
More -> Sharepoint List and then following the steps in the wizard, so
I know it is possible. Just not sure how to recreate this using SQL
Server as the destination for the data.
You can go BCS (Business Connectivity Services) or build something custom using a connector like http://www.bendsoft.com/net-sharepoint-connector/
Here is a small guide on BCS http://zimmergren.net/technical/sp-2010-programmatically-work-with-external-lists-bcs-in-sharepoint-2010

Data in SQL Server 2008 Express edition does not show up after insert?

I have a SQL Server 2008 Express edition database and I am inserting data to it via a windows application, using Linq-to-SQL. I know the data exists in database because when I query the database I get some data but in SQL Server Management Studio when I right click on a table and click even : 'Edit top 200 rows' or 'Select top 1000 rows' I can not view any data ! any helps ?
Assuming you're using the User Instance and AttachDbFileName= approach - I would argue this approach is severely flawed. Visual Studio will be copying around the .mdf file and most likely, your INSERT works just fine - but you're just looking at the wrong .mdf file in the end!
If you want to stick with this approach, then try putting a breakpoint on the myConnection.Close() call - and then inspect the .mdf file with SQL Server Mgmt Studio Express - I'm almost certain your data is there.
The real solution in my opinion would be to
install SQL Server Express (and you've already done that anyway)
install SQL Server Management Studio Express
create your database in SSMS Express, give it a logical name (e.g. VictoryDatabase)
connect to it using its logical database name (given when you create it on the server) - and don't mess around with physical database files and user instances. In that case, your connection string would be something like:
Data Source=.\\SQLEXPRESS;Database=VictoryDatabase;Integrated Security=True
and everything else is exactly the same as before...
I believe LinqToSql has a "Save" command that actually writes the data to the database. Until that happens you are merely holding it in memory.
ETA: see this question and its answers

Need to create a graph/report using any report engine for SQL database

I have a table created in my SQL DB with data filled. I want to create a report out of it with visual display (Graphs). If anyone has done it, please can you suggest if there are any free report engines and how to proceed with my work? I have found one report engine in inetsoft but it is paid.
I am using a MySQL Database. My table layout has 4 columns where 2 areintegers and 2 are strings. I'm using Eclipse, Java, Selenium on a Mac as development environment. I tried with all possible keywords in internet to get freeware to plot the graphs. But I did not find any.
I have explored many reporting tools which are free (data vision) but they don't support graph/chart display.
One more requirement is that the report should be dynamic. that means user is going to select parameters from the report window, which type of chart he wants to display etc. So can anyone help me find such a free tool?
myDBR offers free version and extensive set of available charts in the web reporting system. Supports MySQL, MS SQL Server and Sybase (both ASE and SQL Anywhere).
If you have MS sql server, sql server reporting services is free.

What's the best way to get table creation scripts from a table created in VS 2010?

I've been playing around with hosting on discountasp.net and am in the process of hosting my second web app. Being that discountasp charges you per database and not per sql server or total space used by all of your databases, both apps need to share one database
I need to create all of the tables from the database used by the second application in the live database. I can't just import the mdf file because that would drop all of the data already stored by the first application. Is there a way to automatically generate the scripts or simple sql commands to create the tables in the mdf file from within visual studio?
Also, since multiple applications will ultimately use the same database I'd like to add a prefix to each table names - like App1_Table1. Is there a simple way to rename tables inside VS 2010? Further is there a way to rename the tables but have the entities framework ignore the prefix when generating it's classes?
Thanks for your help, your answers will save me a ton of time I could be programming with :).
There are many options available to you.
In Visual Studio there's database schema compare functionality.
ScriptDb is a simple console app written in C# that uses SQL Management Objects (SMO) to script all the objects in a database. It will work against any SQL Server 2000 or 2005 database. It creates a directory tree structure with a similar hierarchy to that in Object Explorer in SSMS, with a separate file for each object.
There's also an option to script database objects from SSMS. Right-click on a database -> Task -> Generate scripts.

VS2010 ultimate DataBase Project + SQL Server 2008: Updating Project from Database

this is a quick question:
I have this Database Project in a Web app solution with the real database. I want to update the database using SQL server managment studio, and then update the corresponding VS project.
This can be done?
I know that you can update the scripts in the project, but I'm not the SQL kind of guy, i rather do this changes using Mangment studio...
Thanks in advance
Update: Okay, the point is that I want to make changes (if I have to) on the database, using Sql Server Managment studio, and then update the scripts in the Visual Studio DataBase Project, instead of make my updates on those scripts, because I don't feel confortable writing SQL commands. Now what I do is to recreate everytime the Database Project (delete and then create again), this is what I want to avoid
Also, I have Visual Studio 2010 Professional.
It is very achievable in VS2010 Premium and I am currently doing what you describe with a Database Project and a Schema Comparison item.
Sigd is not correct in saying you can only compare Database/Project Compare, you can also compare Project / Database and Database / Database
You can achieve this using the Schema Compare feature, but this is only available with the Premium or Ultimate editions of Visual Studio, not the Professional edition.
In many cases this is possible using Red Gate SQL Compare Pro, although I should warn you that this is not a fully supported scenario just yet (I'm the product manager for this tool so I'd welcome your feedback if you go this route!).
Red Gate's SQL Source Control better fulfills your suggested way of working, although this won't help you just yet as we don't tie into VS Database Projects. Again, this is something we are considering for an upcoming release. You're welcome to try it and let us know what you think.
http://www.red-gate.com/products/SQL_Source_Control/index.htm
If only the Schema Compare tool did what it's name suggests.
Unfortunately it is a "Database/Project Compare". So my project which includes only a single schema, when compared with the database, generates loads of Create actions for all the other schema objects present in the database.
Nice idea, needs work.