AllExperts > Experts 
Search      

Visual Basic

Volunteer
Answers to thousands of questions
 Home · More Questions · Answer Library  · Encyclopedia ·
More Visual Basic Answers
Question Library

Ask a question about Visual Basic
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Ravindra
Expertise
visual basic application programming from design to access information, sql, engineering and commercial applications. access databases, excel. Optional: 1) if you want me to spend quality time and do special work, i expect to be paid a reasonable price for my time. 2) if you are pleased with my reply you could consider a donation of 1$. 3) you can visit my website http://ravindra.coolpage.biz (under constrn)

Experience

Past/Present clients
project work for a Norway company, and a Canadian company completed. Freelance Project work and Teaching
teaching vb

 
   

You are here:  Experts > Computing/Technology > Basic > Visual Basic > Regarding datagrid

Topic: Visual Basic



Expert: Ravindra
Date: 7/18/2008
Subject: Regarding datagrid

Question
QUESTION: Sir, I want to display records in datagrid from sql database ..How can I do that?????/ Kindly help me out of this problem...... I m using vb6.0 with sql

ANSWER: put ADODC  on the form (available from general components).point this to your database, keep it open, then set the ADODC's recordsource to the table

set the datasource of the datagrid to adodc.
thats it

---------- FOLLOW-UP ----------

QUESTION: Sir, I have put ADODC on my form . On its recordsource property I wrote following code;;;;select * from process,,where process is my database & I have opened connection but still is not working ..... here is the code




Call concall
Dim obj As Object
Dim strstrs1 As String

'strstrs1 = "select count(*)as cc from process where cust_date between '" & lbldate.Caption & " 00:00:01 AM' and '" & lbldate.Caption & " 23:59:59 PM' and response in('Request Call back','Not Interested','Not Eligible','Do not Call','Appointment','Customer Not Available','Wrong Number')" '"
strstrs1 = "select * from process"
con.Open
Set rs = New ADODB.Recordset
rs.Open strstrs1, con, 3, 3
If rs.EOF <> True Then

'MsgBox rs(3)
'Set obj = DataGrid1.DataSource
'Set obj = Grid.DataSource
'   If (DataGrid1.DataMember <> Empty) Then
 '      Set rs = obj.DataSource
  ' Else
   '    Set rs = obj
   'End If
   'If (TypeOf rs Is ADODB.Recordset) Then
    '   Set GetGridRecordset = rs
   'Else
    '   Debug.Print "GetGridRecordset", "No recordset for grid ", Grid.Name
   'End If
   'Set rs = Nothing
   'Set obj = Nothing
'Set DataGrid1.DataSource = rs
DataGrid1.Columns(0).Caption = "Cust_Name"
DataGrid1.Columns(1).Caption = "Agent_Name"
DataGrid1.Columns(2).Caption = "Camp_Name"
'lblccount.Caption = rs("cc")
'con.Close
Else
con.Close
End If

Answer
your coding is improper. you use object, adodb, adodc everything. and for dates your coding makes me tear my hair. Pl. Dont invent code, you must follow normal coding procedures.
for datagrid you dont code the columns like that.
god knows where you got this code.

Add to this Answer    Ask a Question



  Rate this Answer
   Was this answer helpful?
Not at allDefinitely              
   12345  

     
About Us | Advertise on This Site | User Agreement | Privacy Policy | Help
Copyright  © 2008 About, Inc. About and About.com are registered trademarks of About, Inc. The About logo is a trademark of About, Inc. All rights reserved.