Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
C

Christian Yeates

@Christian Yeates
About
Posts
2
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Binding source does not update when the linked table is updated in code.
    C Christian Yeates

    Hello All, I am currently in the process of adapting an application that previously worked only with Microsoft Access to work with SQL server or Access. Previously, all database interaction was designed based upon using the XSD file to create queries (etc). I wasn't sure how to handle the new situation with two types of database using the visual methods (e.g. did not want two separate datasets (etc) so I created a static class that contains a function as follows: public static DataTable SelectRows(string connectionString, string queryString) The function will connect to either type of DB based on the connection string and will run the query held in queryString returning a table of the selected records. I create a binding source and assign it to a table called masterTable as follows: cards_photo_accesslevelBindingSource.DataSource = masterTable; I then have a DataGridView that points to the binding source as follows: dgNavigatorTable.DataSource = cards_photo_accesslevelBindingSource; At various times in my code, I call the SelectRows method and store the returned table over the top of the masterTable as follows: masterTable = MyQuery.SelectRows(MyConnectionStrings.getConnectionString(), "SELECT * FROM (Cards LEFT JOIN Photo ON Cards.Card = Photo.Id)LEFT JOIN AccLevel ON Cards.AccessLevel = AccLevel.AccessLevel WHERE Cards.FirstName LIKE '" + tbFirstName.Text + "%'"); My first concern is that the binding source does not update in relation to the update of the table. I have found that the only way to get the binding source and associated DataGridView to update after my masterTable has changed is to re-assign it as follows: // This seems necessary to update the navigator linked to the binding source cards_photo_accesslevelBindingSource.DataSource = masterTable; Even using this naive technique, I also need at this point the PositionChanged event to fire on the binding source as it used to when I would call a Fill method on the datasource before I replaced this method with my SelectRows method. I haven't done much C# for a while and previously have always used an XSD file for my database connection and queries and therefore I assume that I am using the binding source and DataTable in an illegal and naive way? I will keep searching the web for an answer and apologise in advance for my lack of understanding. Regards, Chris

    Database database csharp sql-server wpf wcf

  • MS Acess SQL Query using VS Query Builder and Variable Field Names
    C Christian Yeates

    I am using the Query Builder in Visual Studio to fill my Dataset but one of the field/column names is unknown until runtime; therefore I wish to specify this on the fly. My current query is as follows: SELECT Cards.Id, Cards.Card, Cards.FirstName, Cards.LastName, Cards.AccessLevel, Cards.StartDate, Cards.EndDate, Cards.fTitle, ?, Photo.Id AS Expr1, Photo.Photo, AccLevel.AccessLevel AS Expr2, AccLevel.Name AS AccessName FROM (Cards LEFT JOIN Photo ON Cards.Card = Photo.Id) LEFT JOIN AccLevel ON Cards.AccessLevel = AccLevel.AccessLevel The question mark represents a variable field name. Below is the code which fills the dataset by calling the query above - although for now, I have passed it a fixed string which represents one of the fields in the ‘Cards’ table and should replace the question mark in the query: cards_Photo_AccessLevelTableAdapter.Fill(MyDataSet.Cards_Photo_AccessLevel, "Cards.fDepartment"); Although my code builds ok, an exception is caused when the Dataset is filled as above. Any help would be much appreciated!! Regards, Christian

    Database database visual-studio question csharp help
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups