Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Cannot update textbox
Message
De
22/09/2002 01:42:08
 
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00703115
Message ID:
00703143
Vues:
18
Sorry Don ... you mentioned that it worked fine when you were using a grid, so I assumed that you already had code for the update. I guess it depends on how you're doing stuff or plan to do stuff ... IOW, you can update by calling a SP with a SqlCommand.ExecuteNonQuery() after manually setting the parameters that your SP requires. Or ...you can rely on the DataAdapter.Update() to handle all that for you (actually, when you let the DataAdapter do it for you, there's a few extra things you have to do to set it up ... not having really done that myself, I don't think I'll post any code for that). But, they way we've done it with rolling-our-own update is like this:
SqlCommand sc = new SqlCommand("MyUpdateSP", this.oConnection);
sc.CommandType = CommandType.StoredProcedure;
sc.Parameters.Add("@MyParameter", MyParmValue);
sc.ExecuteNonQuery();
HTH,
~~Bonnie


>Thanks Bonnie, I'm working on it now. I've easily converted it to VB, but still nothing is saved.
>
>In the last lines of your sample you include:
>
> ds = oData.GetChanges();
>> // code follows to handle the updates
>
>Well the code to handle the updates is excatly what I'm looking for. I would LOVE to see how you are handling that - in C# or any other .Net language!
>
>Up to that point all my code works. But the update itself continues to fail.
>
>Thanks
>Do
>
>>Don,
>>
>>Not 100% sure, but perhaps you need to issue an EndEdit() for the dataset row. (Hopefully that's the same syntax in VB ... I use C#). Some controls don't seem to automatically do that and others do. I have a call in my Save() method that generically spins through each row in each table in the dataset and issues an EndEdit(). I posted this code in another thread, but it's easier for me to just post it again instead of trying to find the other thread. It goes like this (this is C#, you'll have to substitute the correct VB code):
>>
>>
>>private void EndTheEdit(DataSet ds)
>>{
>>  for (int nTable = 0; nTable < ds.Tables.Count; nTable++)
>>  {
>>    for (int nRow = 0; nRow < ds.Tables[nTable].Rows.Count; nRow++)
>>    {
>>      if (ds.Tables[nTable].Rows[nRow].HasVersion(DataRowVersion.Proposed))
>>        ds.Tables[nTable].Rows.[nRow].EndEdit;
>>    }
>>  }
>>}
>>
>>
>>Call this method from your Save() method, like this:
>>
>>
>>private bool Save()
>>{
>>  DataSet ds;
>>  this.EndTheEdit(this.oData);
>>  if (this.oData.HasChanges())
>>  {
>>    ds = oData.GetChanges();
>>    // code follows to handle the updates
>>  }
>>}
>>
>>
>>Sorry to post this in C#, but if I tried to translate it to VB, I'd probably miss something somewhere since I'm not familiar at all with VB. Of course, this may not even be what your problem is, but I'm guessing it might have something to do with it.
>>
>>HTH,
>>~~Bonnie
>>
>>
>>
>>>I am learning VB.net, I am an experience VFP programmer.
>>>
>>>I cannot get a text box bound to a dataset field to update properly.
>>>
>>>For example, I create the simple Windows form sample based on the Walkthrough, with a grid and a sqlDataAdapter, and it works fine, updates fine.
>>>
>>>I add a textbox to the same form, select "ds1.Companyname" from the Text dropdown. It populates fine on startup. When I type a different name in the text box, then click on the grid, the grid field changes to the new value, and I can update everything fine.
>>>
>>>Now I remove the grid and nothing will update. I build the form from scratch and spend several hours on this, to no avail.
>>>
>>>Can someone help me with updating from textboxes instead of a grid? When I check the dataset value on tracing, it is changing and shows the new value. Where is the reference I need to read?
>>>
>>>Thanks,
>>>Don Meuse
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform