How to update the Dataset to reflect an added column in the data source without deleting the adapter? - vb.net

I've made a dataset using the dataset designer, and I'm trying to add a column to reflect changes made to the database (added a column, nothing fancy). Is there a way to 'refresh' the dataset schema from the datasource without deleting my adapter (and all the methods and queries I've created)?

I know its been a while since you posted but as I was having the same problem and figured out how to do this I reckoned I'll post the solution that worked for me.
Right click on the dataset object you want to update (on the strip at the bottom of your viewpane)
Select "Edit in Dataset Designer"
in the dataset designer, right click on the header of the table you want to add a column to
select configure... this will bring up the sql statement that is used to draw values into the dataset for this table
Edit the sql to include the column you want to include in your dataset's table and click finish i.e. in the select statement, include your columns name in the list
close the dataset designer then go to any controls (in my case its a datagridview), click on the tasks arrow (top right hand corner next to the handle) and select add column
select the newly created column from the list of databound columns and click "add"
select "edit columns" from the task menu
move the column to the correct position (it will always be placed as the last column in your grid and you may not want it to be the last column)
voila, I know its hardly snappy but it beats the hell out of deleting the dataset and then fixing up all the coding errors that come up... also after doing it a few times it'll be like second nature (I hope)
regards
p.s. am working in VS2010

Had to just delete the adapter and the table. It's rather annoying but I guess there really isn't a way around it. Maybe in VS2010 or later versions of .net.

Related

MS Access: Dependent drop down combobox in Split form without affecting the rest? [duplicate]

This question already has an answer here:
How to query combo box of only current record/row in Access data entry form?
(1 answer)
Closed 1 year ago.
I am trying to make a dependent drop down work with my database here but it is giving me a hard time for different reasons that I will explain.
This is what I have:
A form called "tblOTS" (split form based on an actual "tblOTS" table):
As well as a table called "tblAlphaCode":
When looking at the property sheet for the "Alpha Code" combobox (actually called "strOTSAlphaCode") on my tblOTS form, this is what I have:
The current SQL statement under "Row Source" for this strOTSAlphaCode is:
SELECT tblAlphaCode.strAlphaCode, tblAlphaCode.strCategory,
tblAlphaCode.ID, tblAlphaCode.numSortingOrder
FROM tblAlphaCode
ORDER BY tblAlphaCode.strCategory, tblAlphaCode.numSortingOrder;
Basically, when user select an Alpha code in the drop down from "tblOTS" form, it adds the ID of the tblAlphaCodes into the actual tblOTS record.
My goal is to have the user select first a "Category" (here FASTENERS/HARDWARE ...) when adding/modifying an OTS record, and then have the "Alpha Code" drop down dependent on what category was just selected.
I first tried to changed the SQL statement using a WHERE condition on the category field, based on the form category field itself:
SELECT tblAlphaCode.strAlphaCode, tblAlphaCode.strCategory, tblAlphaCode.ID, tblAlphaCode.numSortingOrder
FROM tblAlphaCode
WHERE (((tblAlphaCode.strCategory)=[Forms]![tblOTS]![strOTSCategory]))
ORDER BY tblAlphaCode.strCategory, tblAlphaCode.numSortingOrder;
And created a strOTSAlphaCode.requery in my Form_Current event to update it everytime.
However, it affects the whole form itself as my control source is directly affected by my Row Source in this instance, and the form looks like this:
You can see that the drop down is working beautifully, however, all the fields that do not have the same category as the current record that I work on (FASTENER <> HARDWARE here), are missing their Alpha code (the second record is missing "O-RING" compared to the first picture from this post); this behavior is problematic!
I tried to find workarounds by changing strOTSAlphaCode into a simple text box only containing the Alpha Code ID, added an unbound text box on top with dlookup function to find the actual alpha code related to this ID, and an unbound combobox in between with the exact same SQL statement inside the Row Source Property, that would update the strOTSAlphaCode with some VBA ... not ideal right?? Ahaha. This is why I believe there is a simpler way that I am not aware of, but also I would like to use a "search as you type" code for this combobox later on and this solution was making it very difficult.
How can I make this work? I believe the answer is a simple/different SQL statement to put in my Row Source property, that is probably something related to some type of JOIN statement? Or something else? I expect to write some VBA code to make all of this work flawlessly, but I want to make sure that I have the right SQL statement first.
Thank you June7;
Yes, the link you gave me ( this link ) states 2 solutions, and the second one is the one that I talked about when describing my problem:
for forms in Continuous or Datasheet view, include lookup table in form RecordSource, bind a textbox to descriptive field from lookup
table, position textbox on top of combobox, set textbox as Locked Yes
and TabStop No
So I guess, the answer is that I MUST have a textbox with dlookup setup for my case; I put it on "locked" so that if the user wants to change it by typing in it, he will first have to select the arrow. This will work with what I wanted to do
Cheers,

'Update requires a valid UpdateCommand when passed DataRow collection with modified rows.'

In my application I have three tables all from the same Access database. I have used the Wizard in Visual Studio Express 2019. This is an extension of my unresolved question here.
Database.TwixBindingSource.EndEdit()
Database.NPCsBindingSource.EndEdit()
Database.EffectsBindingSource.EndEdit()
Database.TableAdapterManager.UpdateAll(Database.DatabaseDataSet)
I have these three tables ("Twix","NPCs",and "Effects"). The above code automatically runs every 15 seconds, like an autosave feature. My issue is when I try to edit "NPCs" or "Effects" I recieve the following error:
'Update requires a valid UpdateCommand when passed DataRow collection
with modified rows.'
Most of the online answers in regard to this error are solved by ensuring each table has a Primary Key column that is recognised by Visual Studio in order to automatically generate the necessary commands to edit, updte, delete etc.
However, I am stumped because I have PKs on each table.
The only thing I can think is that it has something to do with the 'TableAdapterManager,'
ALthough I have no clue at this point.
EDIT: I have replaced the UPDATE ALL with individual UPDATES, but the same problem persists...
Database.TwixBindingSource.EndEdit()
Database.TwixTableAdapter.Update(Database.DatabaseDataSet)
Database.NPCsBindingSource.EndEdit()
Database.NPCsTableAdapter.Update(Database.DatabaseDataSet)
Database.EffectsBindingSource.EndEdit()
Database.EffectsTableAdapter.Update(Database.DatabaseDataSet)
Right click on your tableadapter (on the header, not the Fill command), and choose Configure
Click Advanced Options and verify that "Generate I/U/D" is ticked
When this isn't ticked, the resulting TA doesn't have any DML statements built:
If your SELECT statement doesn't select the column that is set as the primary key in the database, then this Generate IUD tickbox may be greyed out, or it will be ticked but the DML statements won't generate. Pay attention to the final page of the wizard. Here is what happened when I made a table "Other" that had no primary key:
INSERT generates, because it's easy to generate an insert on a keyless table, but update and delete cannot be generated
If you don't select the PK column you get a warning:
It's important that your DB tables have a PK; it's not the same thing to declare some datacolumns of a datatable in a dataset to be a primary key. A Dataset is not a database; it may have more or fewer tables/columns and the presentation and datatypes of row data do not have to match the DB. I can see that your dataset screenshot shows some tables have PKs declared in the DataSet side, but this is not a statement that they are definitely PKs on the DB side
Feel free to delete the DataTable; it will delete the TableAdapter too. You can then recreate that one TA by right click, new, tableadapter.. SELECT * FROM table
If you hadn't already realized, remember that you can (and should) declare more queries per tableadapter than just keeping with the basic Fill, which appears to be a SELECT * FROM without a WHERE clause in your case. Personally I always make my first query SELECT * FROM table WHERE id = #id because it's really rare that you want to download a whole table.. You can leave the default as a WHEREless query, but consider adding others, such as SELECT * FROM Twix WHERE Location = #location and naming the query FillByLocation. In code you can then fill just the locations you want, rather than downloading 10000 Twixes into the app just to show some of them (with a rowfilter, i guess)
This question and answers helped me figure out my problem.
NOTE that if your problem is your table (for example you forgot to set a primary key and you go back and fix it in SSMS while debugging) you will need to find the menus in Caius answer, ensure boxes are ticked, and hit Finish if nothing else.
This will refresh something about the statements(unclear what), and allow this to work. Otherwise you will continue to receive these errors as if you'd fixed nothing, and probably continue to search to no avail.

Qlikview Fast Change option is not working

I have created one QV report in which i have added one chart which shows result data.
In that chart properties i have tick fast change allowed type as: Pivot table and Straight table.
My QV desktop version is 12. While selecting one dimension and one measure and click on change the type,at that time it is not working.
I have created my another report in QV version 11 and fast change is working proper over there. Is this the issue of versioning?Or else some property issue?
After clicking on the red highlighted symbol, it still keeps as it is and does not converting to pivot data.
Straight Table:
Pivot Table:
Also below is the Screenshot of the report which i have created in QV version 11. For one dimension and measure,while click on fast change option, it is converting to pivot table as per below:
Can anyone help me out please?
I have already tried by deleting my existing chart and created another new chart with same properties but it is also not working for the new one.
Click on the title of the dimesion and drag it up and to the right. your cursor should go off of the object without releasing the mouse button. to about where my green arrow is.
Then it will look like this

SSRS SQL report builder deleting column

I have a problem with SSRS report builder. Basically what I want to do is to delete a column. I have a report that someone else made and there is 1 column (xxx) that no longer exists in data source tables so I need to delete it.
When I go to query designer and delete this column from the code and run it there, it works. I close query designer window and see that list of columns (fields) is updated now and xxx column is not there. Then, I delete this column manually in designer (default screen) and when I try to run the report, It doesn't work:
"The Value expression for the text box ‘XXXDataField’ refers to the field ‘xxx’. Report item expressions can only refer to fields within the current dataset scope or, if inside an aggregate, the specified dataset scope. Letters in the names of fields must use the correct case."
But that field should be already deleted. So I don't know what else I can do, or what it can be linked to. I just want to delete it. Any Idea?
Thank you
If your dataset does not contain xxx but your DataTable has this error is normal
You either delete that column from your table or at lease delete DataSet Binding from table so that SSRS does not try to retrieve that column from DataSet
It will be a reference to the field in another field. For example, if you deleted a column that showed an OrderShipped status, then you might have another text box highlighted based on this.
The error is telling you which textbox is in error. So, click somewhere on the designer, then in the properties window, right at the top, click the dropdown which allows you to choose specific report items, choose XXXDataField (the one named in the error message) and then check the value expression. In there you will find the reference to the column you deleted.

Access Database

I need help in creating an query interface with access database.
In brief, with this query interface I want to see calculated future dates for different steps of a process based on the date the process actually started.
The future dates will always be at a fixed number of days after the start date. I hope I am able to explain this in an understandable manner.
I was thinking of using access forms? Please help me in this. I am not sure of how to proceed with this.
If your data is already in MS Access, then using Access Forms would be your easiest method of displaying that data. If the data is elsewhere, such as in Sql Server, you may be better suited in the long run using a different display technology.
That being said, to select a number of dates, as you would do in Access, you can use the Date Add function. If you had a table Processes with a column StartDate, you could use the query
SELECT *, DateAdd("d",5,StartDate) as "5 Days", DateAdd("d",36,StartDate) as "36 Days"
FROM Processes
to generate a record set to bind your form to. Binding that query to a new form is easy. You just need to change the record source by:
Right click anywhere blank in your new form
Select Properties
Change to the data tab
Click the button next to the text box labeled "Record Source"
Build your query using the built in editor (or, to paste the given SQL, right click in the designer view and select SQL view, then paste)
Close the query building dialog and use your new fields. You can drag them from the field list onto the design surface.