By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,101 Members | 1,359 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,101 IT Pros & Developers. It's quick & easy.

Data Grid problem

100+
P: 123
Hi,

I am using vb. I have data grid on my form. At runtime i am not able to enter data into data grid. I think grid is locked. Do i need to set any property or need to write code to enter as many records as i want at runtime?

I am using DataGrid. Is it ok or i should use DBGrid. My back end is access.
Please help me soon. It is quite urgent.
Mar 21 '07 #1
Share this Question
Share on Google+
20 Replies


vijaydiwakar
100+
P: 579
Hi,

I am using vb. I have data grid on my form. At runtime i am not able to enter data into data grid. I think grid is locked. Do i need to set any property or need to write code to enter as many records as i want at runtime?

I am using DataGrid. Is it ok or i should use DBGrid. My back end is access.
Please help me soon. It is quite urgent.
y dont' u go for Componants VsFlexGrid
Mar 21 '07 #2

100+
P: 149
Hi,

I am using vb. I have data grid on my form. At runtime i am not able to enter data into data grid. I think grid is locked. Do i need to set any property or need to write code to enter as many records as i want at runtime?

I am using DataGrid. Is it ok or i should use DBGrid. My back end is access.
Please help me soon. It is quite urgent.
Hi ,

Refer to this link

http://msdn2.microsoft.com/en-us/library/y4ddh1ac(vs.80).aspx

it might help you solve your problem.

thanks
ansuman sahu
Mar 21 '07 #3

100+
P: 375
The link by ansuman will help you if you are using visual studio 2005
The below is the exact link for it (i presume)
Please do read the tutorial carefully
http://msdn.microsoft.com/library/de...ridControl.asp

First check out the allowaddnew property set it to true
Thereafter if you are using a adodc control then set the relevant properties.
After setting the properties of adodc control right click on the datagrid and choose retrieve fields.

In case you are going to code then set the recordset to the datagrid
here's an example
Here Myrs2 is the record set
'Set on the cursor location
MyRs2.CursorLocation = adUseClient
MyRs2.Open "select * from investmentdetails ", MyCon, adOpenDynamic, adLockOptimistic
'Set the datasource to the record set
Set DataGrid1.DataSource = MyRs2

NEXT TIME ONWARDS PLEASE PUT ON YOUR CODE

Good luck
Mar 21 '07 #4

100+
P: 123
The link by ansuman will help you if you are using visual studio 2005
The below is the exact link for it (i presume)
Please do read the tutorial carefully
http://msdn.microsoft.com/library/de...ridControl.asp

First check out the allowaddnew property set it to true
Thereafter if you are using a adodc control then set the relevant properties.
After setting the properties of adodc control right click on the datagrid and choose retrieve fields.

In case you are going to code then set the recordset to the datagrid
here's an example
Here Myrs2 is the record set
'Set on the cursor location
MyRs2.CursorLocation = adUseClient
MyRs2.Open "select * from investmentdetails ", MyCon, adOpenDynamic, adLockOptimistic
'Set the datasource to the record set
Set DataGrid1.DataSource = MyRs2

NEXT TIME ONWARDS PLEASE PUT ON YOUR CODE

Good luck
I dont want to display records from a perticular table. I want to enter records by my own into Data Grid at runtime. So what is the solution for that?
Mar 21 '07 #5

100+
P: 375
I dont want to display records from a perticular table. I want to enter records by my own into Data Grid at runtime. So what is the solution for that?
DID U TRY OUT THE CODE

'Set on the cursor location
MyRs2.CursorLocation = adUseClient
MyRs2.Open "select * from investmentdetails ", MyCon, adOpenDynamic, adLockOptimistic
'Set the datasource to the record set
Set DataGrid1.DataSource = MyRs2
NOW YOU WILL BE ABLE TO ENTER DATA.
Make sure to set AllowAddNew and AllowUpdate to true
No need any more code it will automatically add the records In case you want to delete set AllowDelete to true
Mar 21 '07 #6

100+
P: 123
DID U TRY OUT THE CODE

'Set on the cursor location
MyRs2.CursorLocation = adUseClient
MyRs2.Open "select * from investmentdetails ", MyCon, adOpenDynamic, adLockOptimistic
'Set the datasource to the record set
Set DataGrid1.DataSource = MyRs2
NOW YOU WILL BE ABLE TO ENTER DATA.
Make sure to set AllowAddNew and AllowUpdate to true
No need any more code it will automatically add the records In case you want to delete set AllowDelete to true

No, Still i am not able to enter new record in data grid. You dont understand my question. I dont want to display records of perticular table in grid. I want to add records in grid at runtime. Grid will be blank at runtime and i want to enter data in it. Neither cursor is coming in first column and first row nor i m able to enter the record
Mar 22 '07 #7

100+
P: 138
you can better use the component 'VSFlex' to write at the run time
Mar 22 '07 #8

100+
P: 123
you can better use the component 'VSFlex' to write at the run time
I dont understand ur reply. you have asked me to use FlexGrid? But in MSFlex Grid i wont be able to edit cell, right?

How to enter data in that at runtime? Plz let me know
Mar 22 '07 #9

vijaydiwakar
100+
P: 579
I dont understand ur reply. you have asked me to use FlexGrid? But in MSFlex Grid i wont be able to edit cell, right?

How to enter data in that at runtime? Plz let me know
Shailja ,
MSFlexgrid is not editable.
That's y i had suggested u to use Componant One's VsFlexGrid
Try It
Good Luck
Mar 22 '07 #10

100+
P: 123
Shailja ,
MSFlexgrid is not editable.
That's y i had suggested u to use Componant One's VsFlexGrid
Try It
Good Luck
Thanks for the reply.Can u tell me how to add that component? I have never used it. How to add it and what code should i write to enter data at runtime?
Mar 23 '07 #11

vijaydiwakar
100+
P: 579
Thanks for the reply.Can u tell me how to add that component? I have never used it. How to add it and what code should i write to enter data at runtime?
See this is the third part componant.
So u have to manage it by urself.
for run time editing no need to code any more its by default editable i.e. u've to set its editable property =0 or 1 or 2 or 3
try it Good Luck
Mar 23 '07 #12

100+
P: 375
See this is the third part componant.
So u have to manage it by urself.
for run time editing no need to code any more its by default editable i.e. u've to set its editable property =0 or 1 or 2 or 3
try it Good Luck
Shailja
Kindly let me know one thing. Are u connecting datagrid with ADODC control or are you using ADODB.
In case you are using ADODB I am at complete loss to understand why and where did my code fail in entering data.
I not only completed my project using that code. But got installed at the client's place with much success.
Mar 23 '07 #13

100+
P: 123
See this is the third part componant.
So u have to manage it by urself.
for run time editing no need to code any more its by default editable i.e. u've to set its editable property =0 or 1 or 2 or 3
try it Good Luck

How do i get the component? From which site, i will get that component? Can u suggest me site? Bcoz VB does not provide that component.
Mar 27 '07 #14

100+
P: 123
Shailja
Kindly let me know one thing. Are u connecting datagrid with ADODC control or are you using ADODB.
In case you are using ADODB I am at complete loss to understand why and where did my code fail in entering data.
I not only completed my project using that code. But got installed at the client's place with much success.
I am using ADODB. Why I need to connect datagrid as i dont want to display records from perticular table. I want to enter by my own. Is it possible with datagrid or not?
Mar 27 '07 #15

100+
P: 123
See this is the third part componant.
So u have to manage it by urself.
for run time editing no need to code any more its by default editable i.e. u've to set its editable property =0 or 1 or 2 or 3
try it Good Luck

How do i get the component? From which site, i will get that component? Can u suggest me site? Bcoz VB does not provide that component. Please tell me site name from where i get that component
Mar 28 '07 #16

P: 12
better can be:

Build the disconnected recordset with the column names of datagrid as its fields
and assign it as datasource.


while saving it to database use this recordsets value:

Suppose you want columns like
First Name Last Name Address

Expand|Select|Wrap|Line Numbers
  1.     with rs.fields
  2.          .append "[First Name]",adBSTR
  3.          .append "[Last Name]",adBSTR
  4.          .append "[Address]",adBSTR
  5.     end with
  6.  
  7.     rs.open
  8.  
  9.     set dtgrid.datasource=rs
  10.  
Mar 28 '07 #17

100+
P: 123
better can be:

Build the disconnected recordset with the column names of datagrid as its fields
and assign it as datasource.


while saving it to database use this recordsets value:

Suppose you want columns like
First Name Last Name Address

Expand|Select|Wrap|Line Numbers
  1.     with rs.fields
  2.          .append "[First Name]",adBSTR
  3.          .append "[Last Name]",adBSTR
  4.          .append "[Address]",adBSTR
  5.     end with
  6.  
  7.     rs.open
  8.  
  9.     set dtgrid.datasource=rs
  10.  
I dont understand your reply. Can you give me complete code for disconnected datasource. How to make FlexGrid to VSFlexGrid?
Mar 28 '07 #18

P: 12
your prime requirement was data entry in Datagrid.

This technique is suitable for you.
Mar 28 '07 #19

100+
P: 123
your prime requirement was data entry in Datagrid.

This technique is suitable for you.

I dont understand your code, you have given before. Please give me complete code. On which event, i should write this code. The code you have given for what, for Data Grid or for VSFlex Grid. Please let me know
Mar 28 '07 #20

P: 12
write this code on form load and it is for Datagrid control.
Mar 28 '07 #21

Post your reply

Sign in to post your reply or Sign up for a free account.