|
There is nothing to fix. You just have to realise that there is a difference between the key values in the database, and the key values that the dataset uses to identify the records before they have been added to the database.
The dataset could use a method to create key values that is more like the method that the database uses, but that would only mean that the values would end up the same more often, but not always. There is no telling what the key value will be in the database until you have actually added the record to the database.
Also, the key field doesn't always increment by one. It can be set to start at any value and increment by any value, or even pick a random number.
---
single minded; short sighted; long gone;
|
|
|
|
|
I'm binding textbox controls on a form to a dataset.
So what you are telling me is; I can only do one operation at a time using a dataset. If the database table is empty, then the dataset generated for this table can only have records added.
If I genenerate a dataset from a table that contains existing records I can only do one operation; either edit records or add records. I can't add new records and then use the navigation buttons on the BindingNavigator control to go to other records that need to be edited.
If this is the nature of the ADO.NET methodology then I'll have to disable the navigation buttons when the user selects add new records, and the reverse of this is to disable the ability to add records when in edit mode.
Am I right is my assumption?
Thanks
Quecumber256
|
|
|
|
|
Quecumber256 wrote: So what you are telling me is; I can only do one operation at a time using a dataset.
No. That's no what he said. A DataSet, or DataTable, can hanve multiple operations at the same time.
But, when records are added to the DataSet, the PK fields will get temporary values since the dataSet has no way of knowing what the next available key value should be. When the DataSet is finally written back to the database, the database will assign a new PK value, not the DataSet.
|
|
|
|
|
I think I have found the glitch. When a user is moving through the dataset the current position pointer is at the record the user is editing. If the user chooses to add a new record it will add a new record at the current position; underneath the record that was just edited.
Here is a sample of what happened when I edited and added records in one operation and then updated the dataset.
TableName: tblBindings
7 TST2 7 2nd Test Record Added to Existing DS
11 14
12 TST7 12 Record 7
13 TST8 13 Record 8
14 TST9 14 Record 9
15 TST2 7 2nd Test Record Edited to Existing DS
Is there a way to force the record pointer in the dataset to go to the end of the dataset, and after it is at the end of the dataset then append the new record onto the dataset?
Thanks,
Quecumber256
|
|
|
|
|
No. The DataSet, nor any database, doesn't care about the order of records. Sorting is best left up to the UI, not the data layer.
|
|
|
|
|
On the UI form I bound the four textboxes to the four columns in the dataset.
txtID is bound to RecID, txtOrdinal is bound to column Ordinal, txtCode is bound to column Code, and txtName is bound to column Name. This way when I navigate through the dataset I know which record I'm looking at.
I read an artical this morning about setting the DataSet Autoincrement to -1 and 0. This is suppose to insure that the ID#'s differ between records added and records that were retrieve from the database.
If I add new records using a negitive auto increment and records that are read into the dataset from a database will have positive increments it should take care of my overwrite and record disjunction problems.
Thanks,
Quecumber256
|
|
|
|
|
i create a crystal report with a dataset.
dataset depends on selection of fields.
i try to show these selected fields on report
how i do it
as i place fields at design time
i try to bind than i got blank space in between.
how i remove it
plz tell me.
ajeet
|
|
|
|
|
Crystal Reports requires a Typed Dataset which, i believe, means you cannot do what you want.
Steve Jowett
-------------------------
Sometimes a man who deserves to be looked down upon because he is a fool, is only despised only because he is an 'I.T. Consultant'
|
|
|
|
|
Hi Ajeet, Try this one
add a form & place a crystalReportViewer control on this form
Dim ob As CrystalSmallLabel = New CrystalSmallLabel
'CrystalSmallLabel is crystal report
Dim ds As New DataSet
Dim da As New OleDbDataAdapter
Dim str As String
str = "select * from label where id=" & id & ";"
mdGlobal.myconnectionOpen() 'mdglobal is module which contain
'procedure to build connection string
da = New OleDbDataAdapter(str, mdGlobal.conn)
da.Fill(ds)
ob.SetDataSource(ds.Tables(0))
CrystalReportViewer1.ReportSource = ob
'CrystalReportViewer1 is CrystalReportViewer control
Me.Show() ' me is the form which contain CrystalReportViewer control
ob.PrintToPrinter(NoOfCopy, False, 0, 0)
'if want direct printing to printer then use above statement
End If
hope this helps
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
|
|
|
|
|
Hi,
Please tell me how to allocate memory using Marshal.AllocHGlobal in VB. I am very new to this VB. I am using the code as follows.
Dim returnValue As Long
returnValue = Marshal.AllocHGlobal(250)
But, it's giving the error at run time saying that "Object required".
Can any body please address this issue? If possible please give me the sample piece of code.
Thanks in advance,
AR Reddy
|
|
|
|
|
|
None of this stuff works in VB6.
|
|
|
|
|
This won't work at all. You're trying to use VB.NET code in VB6. VB6 doesn't have a Marshal class.
What does the code look like that you're trying to translate to VB6?
|
|
|
|
|
Then how can we allocate some memory in VB6? is it possible? if yes how can we do this? please give me the sample code if u have.
Thanks
AR Reddy
|
|
|
|
|
Stop. Hold it.
Show us the code that you're trying to translate. Maybe there is an alternative you can use or you might not have to allocate the memory at all!
|
|
|
|
|
hi,
I want to Assign a image to Label Control Dynamically. My Image Is in Resource folder within Solution. I already assign one image to this label control at design time. but at run time at particular condition i want to change the image with other one(Note that i add this image to Resources)
any help will be appreciated
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
|
|
|
|
|
Have you tried using the ImageList control??
this control enables you to add images (either in design time or run time) then from this control you can retreive the image you want. You have two options to get an image, either by using its index or by using the file name of the image.
hope this helps
|
|
|
|
|
Hi alhokail,
i try to add image to imagelist control, but problem is that this control Fix the size for all Image contain within it. when we reterive image from this control then size of all image is same.
i want to ask that how can i save the original size of each image with ImageList control.
Thanks in advance
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
|
|
|
|
|
it seems that you can't control the size of the imagelist as i thought. I say lets return to your resourses folder and try accessing it by supplying the path of the folder to the Image.FromFile function. the resourse folder should be in the executable path if you are only supplying the "Resourses\Image.jpg" to the function.
|
|
|
|
|
hi
can any provied sample code for wininet in vb.net.
for internetwritefile,internetfindnextfile, structure WIN32_FIND_DATA.
tx
|
|
|
|
|
i am doing memory profiling of my application
it shows many string literals staying in memory after closing the
forms where they were used.
Can anyone plz suggest, what is alternative to string literals
because it dont get disposed and increase memory on opening the forms.
Thanks
Milan
|
|
|
|
|
String literals are never disposed. They are compiled into the static data of the assembly, and when you create a string object from a literal, you just get a reference to the static data.
---
single minded; short sighted; long gone;
|
|
|
|
|
then why the profiler is showing me it in memory
|
|
|
|
|
Milan@DIGICorp wrote: then why the profiler is showing me it in memory
Where else would it be?
|
|
|
|
|
i mean that after closing the form where i have used string literal
they dont realease memory they have used
they are of age 40-45 and more.
i think they should be removed as i close the form or the next gc call
|
|
|
|