Click here to Skip to main content
15,913,487 members
Home / Discussions / Database
   

Database

 
AnswerRe: Using dynamic SQL Pin
David Mujica28-Jun-10 6:05
David Mujica28-Jun-10 6:05 
AnswerRe: Using dynamic SQL Pin
PIEBALDconsult29-Jun-10 18:29
mvePIEBALDconsult29-Jun-10 18:29 
GeneralRe: Using dynamic SQL Pin
Tim Carmichael30-Jun-10 7:29
Tim Carmichael30-Jun-10 7:29 
GeneralRe: Using dynamic SQL Pin
PIEBALDconsult30-Jun-10 15:57
mvePIEBALDconsult30-Jun-10 15:57 
Questionxp_cmdshell Pin
It_tech28-Jun-10 2:11
It_tech28-Jun-10 2:11 
AnswerRe: xp_cmdshell Pin
J4amieC28-Jun-10 2:28
J4amieC28-Jun-10 2:28 
GeneralRe: xp_cmdshell Pin
It_tech28-Jun-10 3:17
It_tech28-Jun-10 3:17 
QuestionBinding source does not update when the linked table is updated in code. Pin
Christian Yeates28-Jun-10 0:17
Christian Yeates28-Jun-10 0:17 
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:

<br />
public static DataTable SelectRows(string connectionString, string queryString)<br />


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:
<br />
cards_photo_accesslevelBindingSource.DataSource = masterTable;<br />


I then have a DataGridView that points to the binding source as follows:
<br />
dgNavigatorTable.DataSource = cards_photo_accesslevelBindingSource;<br />


At various times in my code, I call the SelectRows method and store the returned table over the top of the masterTable as follows:
<br />
masterTable = MyQuery.SelectRows(MyConnectionStrings.getConnectionString(),<br />
            "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 + "%'");<br />


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:

<br />
// This seems necessary to update the navigator linked to the binding source<br />
cards_photo_accesslevelBindingSource.DataSource = masterTable;<br />


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
Questionxp_cmdshell [modified] Pin
It_tech26-Jun-10 23:27
It_tech26-Jun-10 23:27 
AnswerRe: xp_cmdshell Pin
J4amieC27-Jun-10 21:53
J4amieC27-Jun-10 21:53 
GeneralRe: xp_cmdshell Pin
It_tech28-Jun-10 2:21
It_tech28-Jun-10 2:21 
GeneralRe: xp_cmdshell Pin
J4amieC28-Jun-10 3:32
J4amieC28-Jun-10 3:32 
GeneralRe: xp_cmdshell Pin
It_tech28-Jun-10 4:09
It_tech28-Jun-10 4:09 
GeneralRe: xp_cmdshell [modified] Pin
It_tech28-Jun-10 3:28
It_tech28-Jun-10 3:28 
QuestionQuery for multiple occurance Pin
Nikhil Bhivgade26-Jun-10 2:16
professionalNikhil Bhivgade26-Jun-10 2:16 
AnswerRe: Query for multiple occurance [Solved] Pin
thatraja26-Jun-10 4:02
professionalthatraja26-Jun-10 4:02 
QuestionJoin tables from different server Pin
Naunt24-Jun-10 23:58
Naunt24-Jun-10 23:58 
AnswerRe: Join tables from different server Pin
Covean25-Jun-10 0:55
Covean25-Jun-10 0:55 
AnswerRe: Join tables from different server Pin
CitrusTech25-Jun-10 1:02
CitrusTech25-Jun-10 1:02 
AnswerRe: Join tables from different server Pin
J4amieC25-Jun-10 1:29
J4amieC25-Jun-10 1:29 
AnswerRe: Join tables from different server Pin
Naunt25-Jun-10 3:00
Naunt25-Jun-10 3:00 
QuestionJan-December chart with specific information Pin
Dave McCool24-Jun-10 22:44
Dave McCool24-Jun-10 22:44 
AnswerRe: Jan-December chart with specific information Pin
riced25-Jun-10 1:21
riced25-Jun-10 1:21 
GeneralRe: Jan-December chart with specific information Pin
Dave McCool25-Jun-10 1:39
Dave McCool25-Jun-10 1:39 
Questionsql function to calculate work hours of an employee Pin
Thanusree Duth24-Jun-10 21:03
Thanusree Duth24-Jun-10 21:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.