473,396 Members | 1,895 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

VB.NET,winform- difficulties in datagridview

66
hi,
i was using .net1.1.. now i am using .net2.0 and sqlserver2005
in my form i have a datagrid and i want view the contents of contents of table how write the code in vb.net 2.0.. i tried the following code but its not working
plz help me
Expand|Select|Wrap|Line Numbers
  1.  
  2. Imports System.Data.SqlClient
  3. Public Class Form1
  4.  
  5. Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
  6.  
  7. Dim con As New SqlConnection("Data Source=localhost; Initial Catalog=N0C7G6\Databases\company; Integrated Security=SSPI")
  8. Dim ad As New SqlDataAdapter("select * from emp", con)
  9. Dim ds As New DataSet
  10. ad.Fill(ds)
  11. DataGridView1.DataSource = ds
  12. DataGridView1.DataBindings()
  13. End Sub
  14.  
May 30 '08 #1
3 1171
Curtis Rutland
3,256 Expert 2GB
You are filling a DataSet, but you aren't specifying what table in the DataSet is the binding source. Try this:
Expand|Select|Wrap|Line Numbers
  1. .
  2. .
  3. .
  4. ad.Fill(ds,"empTable")
  5. Dim table as System.Data.DataTable
  6. table = ds.Tables("empTable")
  7. DataGridView1.DataSource = table
  8. DataGridView1.Update()
  9.  
I'm not sure what the DataGridView1.DataBindings() is supposed to do, but Update should force the control to refresh itself.
May 30 '08 #2
rekhasc
66
Thanxs for your reply...
but its giving error

Cannot open database "D:\company.mdf" requested by the login. The login failed.
Login failed for user 'N0C7G6\Rekha'.
May 30 '08 #3
Curtis Rutland
3,256 Expert 2GB
Thanxs for your reply...
but its giving error

Cannot open database "D:\company.mdf" requested by the login. The login failed.
Login failed for user 'N0C7G6\Rekha'.
Well, that's a permissions error.
May 30 '08 #4

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

Similar topics

2
by: localhost | last post by:
I am looking for any info on creating an MDI WinForms application that uses the "main executable" as a main window container (along with a menu), but can launch other .exe from a menu that act as...
0
by: cgia | last post by:
I found out that only using winform I can use the winword interop and generate word document in the client machine and connect to a remote database, so that I have made a winform application which...
0
by: zbcong | last post by:
hello in my winform,there is a datagrid,i want to fire some actions when the selected index is changed,but i fail to find the SelectedIndexChanged event to the winform datagrid,why? how can i...
0
by: someone | last post by:
Hi, We are encountering a problem with the DTPicker. This is the situation: We have a DTPicker-control on a VB6 Active-X. The Active-X is used on a .NET winform. the problem: The .Net...
3
by: Skc | last post by:
My client's project consists of about 6 files maintenance programs that uses WinForm and grid for updates with lookup finders for each file. There is also a User file and security. There are...
2
by: J.Marsch | last post by:
Ok, so here's a problem you probably don't see every day: We are building an application that must run in a browser, but we need to do some things client-side that would be rather difficult to...
8
by: Sunil Menon | last post by:
Dear All, We are developing applications in ASP.Net...in one of our applications we would like to use a GridControl...we have tried to use a Server-Side Grid control but found the speed to be an...
2
by: jyanmin.fang | last post by:
Hi, In my current project, I need to embed an .NET winform usercontrol in the aspx page (via <Objecttag). This winform usercontrol has an event called DoEvent (void DoEvent()). This winform...
0
by: Tom | last post by:
Hi all -- this is my first posting here and I want to start by saying thank you to all the responders. I have done some searching and reading and have learned a few things I didn't even know to...
14
by: Monty | last post by:
Hello, I have created a solution which has both a web UI and a winform UI, the latter is just for administrators. The Web UI (a Web Application Project) and the winform project both...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.