Using data held in an SQL database in Visual Studio - sql

So far, I have created 3 tables in SQL using visual studio. They have been connected to my VB project file and I can view the data held within them using the Database Explorer.
My only problem is: how do I use/make available the data held within each table?
I need to write code which will add a Japanese character (from one of the tables that already exists) to a new table when a check box is ticked. Then I need to write code to update the table and save the changes.
I have absolutely no idea how to retrieve the data held in each table nor how to write a SQL query in VB.
Any help would be appreciated.

Related

Vb sql Accept Changes

I have made a SQL table within Visual Basic 2012.
I then made my dataset for inserting data.
I made a form and linked it to the table adapter and when the program is running it allows the data to be added to the table but when I reopen the application that data is not there.
I have tried two acceptchanges but they don't work. So it is not saving it the data that is in the "temporary table".
Me.TableTableAdapter1.InsertQuery(TextBox1.Text, TextBox2.Text, Dropdownseats.Text, dropdriver.Text)
BusesDataSet1.Table.AcceptChanges()
BusesDataSet1.AcceptChanges()
Does anyone one know why this is happening?????
*Changed the database to MS Access and I am still having problems. *

Executing stored procedure using .dbml file LINQ

Using VS 2013 (VB) and SQL Server 2012.
I execute a stored procedure to populate a gridview using linq.
Dim db As New GMConnectionDataContext
Dim gasHedges = db.GasHedges_create2ndMonth.ToList
The stored procedure returns a result set and has been working fine as in it returns the expected result and the gridview displays as desired.
I added some data to my SQL table and loaded the web page and the new data does not show. IF I execute the stored procedure in SQL Server the new data shows. If I execute the stored procedure in VS the new data shows.
Now the weird bit. If I delete the reference to the stored procedure from the .dbml file then re-add it the new data shows when the page is loaded. I know that when using this file if I add columns to a table then I need to delete it and re-add the table to the .dbml file.
Surely the same isn't the case with stored procedures as they would be unusable. Is there something I am missing?
UPDATED
I think I know why this happening but I don't know how to fix it. The SQL result set has dynamic columns as I use the pivot command in SQL. This means that if a user creates a new Gas company the result set will have another column and the datacontext must interpret that as the SP having changed and still shows the old dataset. This does mean I cannot just delete the SP from the datacontext and re-add it as the web application needs to handle if the user adds another company.
Any changes you make in SQL server are not auto-synched to your .dbml file. If you make table or stored procedure changes you need to delete them from the .dbml file and add them again.
Best practices would dictate that you don't pivot your data in SQL. Pivotting data is not a data related issue; it's presentation and should be done in the presentation layer -- in the application.

Crystal Report Duplicating in details?

so I have a template in Crystal reports using vb.net, I changed my data source location and that source still contains the needed tables for my report, the problem is this... My original template displays the exact report but when I changed its data source it duplicates the data in the details section(e.g I made a query that will show 1 item only,but instead I get 4).
Here is a screenshot of my problem:
(original at http://tinypic.com/r/5by6ih/5)
I want to alter the template rather than to make another one
This is normally down to an issue with the underlying SQL query. If you open the the report in Crystal (or visual studio) you should be able to "Show SQL Query". Run the query in Query Analyser or SQL Server Management Studio and look at the result.
If the underlying reason isn't then immediately apparent please paste the resulting output.

MS Access form not displaying data from the tables

I'm building a new Access 2007 database with a large number of tables. Designed a form with multiple tabs to display the fields from various tables, which all have a relationship with each other. When new data is entered it is all being saved correctly to the various tables. However, when the form is opened it is not displaying any of the data stored in the tables. The form properties seem to be set correctly, it allows additions and editing and is not set for data entry only. Running the query that is the recordsource fails to return any records, which looks like the problem lies there, and yet the recordsource must be correct if it is able to save the new data entered to the right tables. Any ideas on what the problem might be?
Check you database connection If database connection is established correctly then you need to check you database query e.g if you are writing this query
Select * from tableName
Just copy it and run in access sql query editor if that work fine it means some thing is wrong in you form data retrrvil mechanism.
Hope it helps you

Add Description From Excel File to Columns description in SQL

I have a DB (in SQL Server 2008 SP3) include many tables and each tables have a lot of columns, in other hand I have an Excel file include description for any of my DB's columns (In SQL Server Management Studio when you want create a table, in design mode, for each column in property window there is a description field), So I am interesting in add this(Excel) description to description of columns in DB (of course not by hand and one by one), does any one have any idea about this?
Knock up some VBA to iterate through the Excel data, calling the database for each table/column.
The SQL Server stored procedure you want (if I understand correctly) is sp_addextendedproperty to add comments about objects in SQL Server
You can get help from some references given below: please have a look over there, thanks
a. Reading and Writing Excel
b. Reading Excel and then save to your DB