• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 158
  • Last Modified:

SQL Server 2000 and VB

I have a simple application that has a form with a datagrid, text, and command button.  The user can type in a SQL statement in the text box and get the results in the grid, then the user can update data in the table.  

The problem I ran into was if there are more than 1 record displayed in the grid everything works ok.  The user can update the data like an excel spread.  

But if there is only one record in the grid, and the user tries to update it, it acts like it works, but it is not really updating it.  If the user update the 1 record, then turns around and queries it again to see if the update worked, it never works.

Does some know why this would happen?  It this a datagrid control bug?  Or is this a SQL server bug/ weirdness?

  • 3
  • 2
1 Solution
It is not a bug.
By default datagrid updates DB when the current record changed.
when there is only one record (and I think that user not allowed add new rows) user cannot change the record and force datagrid update the DB.
The solution is simple: put a button on the form, name it "Update" and call  to your recordset's .Update method when pressed.

I hope it helps

what are the settings for the DataGrid u r using...??

'coz its working ine here even if  hve one record into it..
strongdAuthor Commented:
Here are the properties to the datagrid:   (I left out the obvious ones like FONT, COLOR, left , top, Row height, etc...)

AllowAddNew = True
AllowArros = True
AllowDelete = True
AllowUpdate = True
CausesValidation = True
ColumnHeaders = True
DataMember = NULL
DataSource = NULL
DefColWidth = 0
Enabled = True
HeadLine = 1
Index = NULL
Netgotiate = False
RighttoLeft = False
TabAcrossSplits = False
TabStop = True
TAG = Null
Visible = true
WrapCellPointer = False

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Could you post the relevant code? How do you access Database?
strongdAuthor Commented:
I use a typical connection string...   I am also using the ADODC control ...

  Connect = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=" & txtUserName.Text & ";password=" & txtPassword.Text & ";Initial Catalog=SysDB;Data Source=myserver"

Adodc1.ConnectionString = Connect
Adodc1.recordsource = 'SELECT * FROM My_TABLE"
  Set DataGrid1.DataSource = Adodc1

strongdAuthor Commented:
Thanks Mike D, I used your suggestion and added a button to the form with the recordset.update command...

It worked great...

Thanks again...

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now