Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Display In DataGrid Control


Hello everyone! First of all, I apologize profusely if this post makes little sense. It's late and I'm sooooo tired and this silly problem is not helping any.

Anyway, here goes:
I have a Data Grid Control on my form called dgdHistory and Adodc callled adoHistory. My problem is that I have tried to link the Adodc control to my Data Grid Control to display the records but it does not display any records. I know it is pulling and working with the recordset because it calculates the correct totals at the end, but no records are displayed in the Data Grid Control.


Code:

rs.Open strSQL, sConn, adOpenKeyset, adLockPessimistic, adCmdText
With adoHistory
.ConnectionString = sConn
Set .Recordset = rs
End With
Set dgdHistory.DataSource = adoHistory
dgdHistory.Refresh
With adoHistory
Do Until rs.EOF
sngCostTotal = sngCostTotal + rs.Fields("TotCost")
sngRateTotal = sngRateTotal + rs.Fields("TotRate")
intTotMin = intTotMin + rs.Fields("Duration")
rs.MoveNext
Loop
End With
Can anyone see what I am doing wrong?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Database Display Using DataGrid Control
I have made a Table using Access and I use VB to display the content of my Table using ADO and DataGrid Control.

My problem is that one of the field in the Table is a Date Field which I format it in Access as Medium Date but when I displayed it in DataGrid Control it is displayed as "1/2/2005".

How can I displayed it in DataGrid Control as "Dec-01-2005"?

One more thing I want to use the set database password and Is their a possiblity that my VB Appz can change the database password on run-time?

Need your help and suggestion.

Thank u.

How To Display A Table In DataGrid Control
hi vbforums members...

im a beginner in Visual Basic. can someone tell how to use datagrid control to display a table in it....

im using MS Access 2003 as back-end and VB 6.0 as front-end.

How To Display Data In DataGrid Control
please tell me how to display data in DataGrid control, the simplest way to do it. please this is very urgent to me

Click Datagrid Row And Display Details To Another Datagrid
hello there..here i need help. i have a datagrid that retrieve data from database.what i want to do with the datagrid is when i click any rows of the datagrid it can display the details of the data (refer to the row that i click) to another datagrid.

is there possible to be done ?

i want to know if there is any procedure that can capture the datagrid row that i clicked

Sql Datagrid Display
I have this datagrid populated from a table. The table has the following fields :
NameHotel, Period_From, Period_To, price1, Price2

The user should be able to click on the datagrid and the information should come up on labels. The catch is: The same hotel might have more than one period and different periods have different prices 1 and 2 e.g
NameHotel:AnyHotel
period_from 01/01/2002
period_To 27/03/2002
Price1 55
Price2 75

and
NameHotel:AnyHotel
period_from 28/03/2002
period_To 31/12/2002
Price1 65
Price2 85

The dates have been chosen from a dtpicker command, but letīs say the user in
this example wanted four days at price1 from 26/03/2002. that would then be 2 days at 55 and two days at 65.

I would like to have it displayed in the format
NameHotel:

2 days at 55 = 110
2 days at 65 = 130
Total= 240

Any help, please?

DataGrid Display SQL
Using:
VB6.0
MS Access DB
DataEnvironemt

Question:
I have a DataBase with a primary Key of AutoNumbers.
I want a DataGrid to Display all the Records that are Contained in a String.

Example, Instead of the DataGrid Displaying all 1 to 50 Records in the DataBase I want it to Display Records number "1 15 23 37" and those 4 Numbers will be dynamic.

Please tell me what to tell my DataGrid.

Display -ve Value In Datagrid
Hi all,

I am using vb6.0 Access 2003

Is there any way that we can display -ve vaules as -ve values in Datagrid.
Data is the result of a recordset.
The data is result of user input. EX: User looks for amount > 1000 or <-1000 [For amount <0 they enter - sign to indicate]
The program works fine except not displaying -ve sign in front of the -ve amounts.
I know to format currency data.
But it will not display whether it is +ve or -ve value.

Code:
Public Sub DataGridFormat()
    Set sfmt = New StdFormat.StdDataFormat
    sfmt.Format = "#,###,##0.00"
End Sub
......
Set grdEditAmount.Columns(3).DataFormat = sfmt



Hope some one will help me.

..................

It is displaying amounts with - as prefix for negative values. I don't how i missed it.




Edited by - sreddy on 8/21/2008 11:09:14 AM

How To Display A Check Box In A Datagrid
Hi,
I need your help.
I have a datagrid control that bind to a table. There are 3 columns bind to a Y/N column which datatype is char(1).
How can I display those columns in the datagrid as checkbox?

Thank you so much,

ConKi

Display Record Set In Datagrid??
Hi I have the code below that queries a database and creates a recordset from it. The code then puts the FirstName value of the record into a textbox. However I also want to display all the records queried in a datagrid. How do I alter the code to allow me to do this? I have a data grid on the form called datDataGrid.

Any help would be greatly appreciated.

Thanks.

Ben.

'Declares the recordset globally for this form
Dim MyRecSet As ADODB.Recordset
-------------------------------------------------------------------
Private Sub btnNext_Click()

' Moves to next record
MyRecSet.MoveNext

' Puts the FirstName value of the first record into a textbox
Me.txtName.Text = MyRecSet.Fields.Item("FirstName")

End Sub
-------------------------------------------------------------------
Private Sub Form_Load()
Dim MyConn As ADODB.Connection
Dim strName As String

'Creating the connection
Set MyConn = New ADODB.Connection
MyConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.3.51;Data Source=C:Documents and SettingsBenDesktopWADE2CourseworkDatabasehogwarts.mdb;"

MyConn.Open

' Creating a recordset from a query
Set MyRecSet = MyConn.Execute("SELECT FirstName, FamilyName FROM Character")

' Puts the FirstName value of the first record into a textbox
Me.txtName.Text = MyRecSet.Fields.Item("FirstName")

' This needs to go at the end because if it is before the selection
' of data from the recordset then it doesn't work.
' MyConn.Close

End Sub

Datagrid:need To Display Enough Cells
Hi all,

I ran a query and return 0 record, the datagrid only display one blank row.

I like to find out if there is a way to default several blank grid cells when there is no record found?

Thanks in advance


Kim

SQL Searching &amp; Datagrid Display
Hello

I have a program that will print the contents of a datagrid and all works well, I just cannot figure out how to fix my search code.

http://img511.imageshack.us/img511/3760/scottsvx0.jpg

I am trying to make it so when the user clicks "Command1" it will filter out anyone who doesnt have "Box Type" 1 and only show those who do.

The way my code is right now, when i open the debug window, the button does give an output of 1 but it doesnt filter the information shown in the datagrid.

Here is my code:


Code:
Private Sub Command1_Click()

strSQL = "SELECT * "
strSQL = strSQL & "FROM hamper "
strSQL = strSQL & "WHERE [Box Type] = 1 "
strSQL = strSQL & "ORDER BY Forename;"

Dim cn As New adodb.Connection
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:databasescotts2.mdb"
cn.Open

Dim rs As New adodb.Recordset
Set rs = cn.Execute(strSQL)

With rs
Do While Not .EOF
Debug.Print (.Fields("Box Type").Value)
.MoveNext
Loop
.Close
End With

Set rs = Nothing
cn.Close
Set cn = Nothing

End Sub

DataGrid Display Question
VB 6 Enterprise, OS = Windows XP Pro

Scenario:
I have a DataGrid that is read only. It can have any number of records(rows). The current "Display" allows 25 rows visible. Therefore, if I have more than 25, I need to use the scrollbar.

I worked out a routine that will print the contents of the complete DataGrid. For example, if the record count = 80, I will get 4 pages of printout ( 3 pages, each showing 25 records, and a 4th page with the balance (5 records),

Problem:
The last page will not only show the last 5 records but it will show the previous 20 (20 + 5 = rows visible).

Question:
Is there any way just to show the last 5 record on the datagrid?

The Code:
' RecordCount = adoTrackSort.Recordset.RecordCount is done in a different sub routine

cdPrint.ShowPrinter
Printer.Orientation = vbPRORLandscape
If RecordCount > 25 Then
ScreenCount = Round((RecordCount / 25), 2)
ScreenCount = Round(ScreenCount)
CountDiff = RecordCount - (25 * ScreenCount)

Else
ScreenCount = 1
End If
If ScreenCount >= 1 And CountDiff > 0 Then
HoldScreenCount = ScreenCount + 1
End If
If ScreenCount >= 1 And CountDiff = 0 Then
HoldScreenCount = ScreenCount
End If
ScreenCount = 1
RowPosition = 1
Do Until (ScreenCount + 1) > HoldScreenCount
' Me.PrintForm
DoEvents
RowPosition = RowPosition + 25
ScreenCount = ScreenCount + 1
dbgTrackSort.Scroll 0, 25
DoEvents
Loop
dbgTrackSort.Scroll 0, (RecordCount - CountDiff + 1)
Me.PrintForm
DoEvents
Call MsgBox("You have " & HoldScreenCount & " Pages of printout for this report.", vbInformation, "Report Pages")

Thanks,
Sam

How Do I Display This Report(datagrid)
i would just like to ask if there is a way to display a whole report plus its "relationship" from the other database table.

im using vb6 and ms access for storage.
datagrid for displaying the data's

if yes please give me some sample of codes so i can have an idea.

Display Records In Datagrid And Others
HI

I want to be displayed records in datagrid. i tried it using given code but it gives error like "rowset in not bookmarkable"

rs3.Open "select * from billauto", cn, adOpenDynamic, adLockBatchOptimistic
Set DataGrid1.DataSource = rs3 ' here it gives error
datagrid1.refresh

and i want to update,delete addnew records directly from datagrid

Please help me

waiting for reply
Thanx a lot

Display Records In Datagrid
hi all,

i want to type some name in my textbox. when i start type something ( i feel in textchange itselft) the datagrid should fill with those records from the table starting with letter i typed in the text box. how can i go about. which grid control is best suit here. i need some suggestions. and the beginning code if possible.

another query is can i able to display the records of two tables in a grid

thanx in advance
saj

ADO - Display Datagrid Or Mshflexgrid
Hello All,

I am using ADO with Access databse.How can I show records of below query in Datagrid or mshflexgrid ? There can one record as well as multiple records against unique mp.regnonew, so I want to display those records. How to set this query to adodc1 when I want to fetch record against unique mp.regnonew.


VB Code:
"SELECT mp.regnonew, pvd.visano, mv.visatype, pvd.visaissuedt, pvd.visavaliddt, pvd.visaissueplace FROM mas_passenger AS mp, pass_visadetail AS pvd , mas_visa AS mv WHERE mp.passid = pvd.passid AND mv.visaid = pvd.visaid AND pvd.deleted = no AND mp.regnonew = '" & lstregno.List(lstregno.ListIndex) & "'"

Display Selection Of A Row In The Datagrid
How do get the Datagrid to highlight the first row of record it's displaying
in code
thks

How To Display A Checkbox In Datagrid
Good morning.
I have a datagrid that bind to a table. The table has 1 column which contains data as either Y or N and has datatype char(1).
How can I present this column in the datagrid as a check box?

In the design time, the property of the datagrid only allow a checkbox that bound to a boolean type col but there is no such a boolean type in SQL Server.

Thank you for your help.
ConKi.

How To Display SQL Result In Datagrid
my sql result is declare as ADODB.Recordset
and now i want to print it out in table form.how?
if there are any method please tell me too

Datagrid Won't Display Data
Set con = New ADODB.Connection
con.ConnectionString = "File Name=" & mstrDatabasePath
'mstrdatabasepath = "C: est.udl"

con.Open
Set rst = New ADODB.Recordset


rst.Open txtSQLString.Text, con, adOpenStatic, adLockOptimistic, adCmdText

Set dbgoutput.DataSource = rst

It just stopped working all of a sudden, syntactically I didn't change anything. The weird thing is I can generate XML, delimited, and HTML based upon the SQL taken from the textbox.

Any idea what might cause this?

How To Display The Particular Record In Datagrid : Vb 6.0
Hi all,
Can anyone tell me how to get a record for particular user or Number
In my sql i,v Pinvoice table following fields
InvNo int1001
ItemNo
001
002
003
Descrption varchar(20)Fan
Chair
Table
Price float
90
100
20
Qty
2
5
10
Gross
180
500
200
so my question is if type the InvNo(1001) in a textbox this all Records(ItemNo,Descrp,Price,Qty,Gross) i need to display in a grid if i type the another Invno then it has to show me the corresponding InvNo whch i specify in the same grid and in below the Grid i need the total for theGross amount , so can anyone tell me how to do this

Problem In Datagrid Display : Vb 6.0
Hi all,
Can anyone tell me how to get a record for particular field, in sql i,v Pinvoice table following fields
InvNo int ItemNo int

Descrption varchar(20) Price float Qty Gross float
1001

090

Fan

30

5

150
1001

080

Table

45

2

90
1002

012

Chair

90

3

270
1002

001

ToolBox

120

1

120

now t want to see the particular invNo details in a datagrid when i type the particular invNo ina Textbox (for example if i type the InvNo -1001 in that textbox the grid shows that 1001 details) what should i do to get the result.
in button click i used this query
sqlstring
sqlstring = "select ItemNo,Descrp,Rate,Qty,Gross from Pinvoice where InvNo=& txtTest.Text"
Adodc1.RecordSource = sqlstring
Adodc1.Refresh
1. "Microsoft[ODBC Driver manager]datasource name not found" so i droped it.
2."Incorrect syntex near&"
3.Method 'Refresh' of object 1Adodc failed"
so i used this way
1. in a Adodc control Recordsource command type AdcmdText i added the following code select ItemNo,Descrp,Rate,Qty,Gross from Pinvoice where InvNo=&
it showed me error msg Incorrect syntex near&" as well page loading & close

so i tried to give the datasource at run time, in a button click event i added this query
plz help me to solve this problem

Display Record On Datagrid
how to display all my records on datagrid ?
i already make the datagrid on my form ( from selecting datagrid component ). but how to define its query source
( i'm using odbc mysql conn) - should i place another component ? what i have to do to make the datagrid display the result of my executed query ?
thanks in advance...

Display Records In Datagrid And Others
HI

I want to be displayed records in datagrid. i tried it using given code but it gives error like "rowset in not bookmarkable"

rs3.Open "select * from billauto", cn, adOpenDynamic, adLockBatchOptimistic
 Set DataGrid1.DataSource = rs3 ' here it gives error
datagrid1.refresh

and i want to update,delete addnew records directly from datagrid

Please help me

waiting for reply
Thanx a lot

DataGrid Display Problem
is there any solution?


Hi

I am using VB, COM+/MTS, ORACLE for application. In VB, to update the records I am using DataGrid with the combination of ADODC.

Table structure is as below
ITEM_MST Table
        CODE
        BRAND
        DESCRIPTION

ORDER_MST Table
        CODE
        ITEM_CODE
        QTY
        UOM

Code:
Set objclsPR = New clsPR
Set ADODC1.Recordset = objclsPR.GetRecorset(dblCode)
Set objclsPR = Nothing
DataGrid1.DataSource = ADODC1


Quote:Class Module
Public Function GetRecorset(Optional ByVal Code As Double) As ADODB.Recordset
    On Error GoTo errHandler
    Dim cn As ADODB.Connection
    Dim rs As ADODB.Recordset
    
    strSql = "SELECT * FROM ORDER_MST "
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    Set cn = New ADODB.Connection
    cn.ConnectionString = CONNECT_STRING
    cn.Open
    
    rs.Open strSql, cn, adOpenDynamic, adLockOptimistic
    
    Set rs.ActiveConnection = Nothing
        
    Set GetRecorset = rs
    
    Set rs = Nothing
    cn.Close
    Set cn = Nothing
    
    If Not mobjCtx Is Nothing Then mobjCtx.SetComplete
    
    Exit Function
errHandler:
    If Not mobjCtx Is Nothing Then mobjCtx.SetAbort
End Function




clsPR is class, objclsPR.GetRecorset is returning the recordset and this recordset i am binding with DataGrid.

I have 6 columns in DataGrid for display.
1.Code
2.Item Code
3.Brand
4.Description
5.Qty
6.UOM

I donot have any problems with columns Code, Item Code, Qty. My Problem starts with BRNAD and DESCRIPTION.

How do I show the BRAND and DESCRIPTION against the selected ItemCode?

If need more explanations, pls ask.


KT





Edited by - Kshitij on 1/28/2004 6:05:11 AM

DataGrid-Display Problem
Hi,

Iam using DataGrid in my application to display the search results.
with Database as MsAccess.

i have used code like this

    rsVS.Open "select Voter_ID, Name, Father_Name, Village, Taluk from PersonnalDetails1 where ID between val(me.txtFrom.text) and val(me.txtTo.text) ", dbVS, adOpenStatic, adLockOptimistic

    Set Me.DataGrid1.DataSource = rsVS


I have my data base column declred as Number


The error message iam getting as Too Few Parameters Expected3

Thanx

DataGrid Click-Display
HI,

Iam Using DataGrid in my application. I got the Datagrid Display.
The First column is my Primary Key, so that i can search the database based on this key.

Now upon clicking any where in the row i want to display the details in another form.
How to go about it.

Thanx,
harry

Problem With Datagrid Display
im using an adodc to display sql queries in the datagrid...this is the sql i use to get my data

SELECT @total:= SUM(i.itemQty) FROM invoiceItemTable i, invoiceTable t, partsTable p WHERE i.itemNum = p.partID AND i.invID = t.invID;
SELECT p.partName as 'Item', SUM(i.itemQty) as 'Quantity', CONCAT((ROUND((SUM(itemQty)/@total)*100)),'%') as 'Percent' FROM invoiceItemTable i,partsTable p WHERE i.itemNum = p.partID AND i.invID = t.invID GROUP BY p.partName;

my concern is that i can't seem to display the third column of my query which is suppose to be the percentage...so far the first two columns of the query displays normally...and i doubt my query is wrong because when i use the same query to print it in the data report...it works fine...

so my question is...why can't i display the thrid column in the datagrid? is there some formating required or something? as far as i know sql queries only return strings right? so there should be no problem in displaying in the grid....

Display DBF File Into DataGrid
Hi all
i am a complete novice in database programming in VB. I have a DBF file whose location and file name is always constant. I want to display it in a form using DataGrid control. I would appreciate it very much, if someone can point me to proper codes.

thanks a lot in advance
karin

DataGrid Display Question
VB 6 Enterprise, OS = Windows XP Pro

Scenario:
I have a DataGrid that is read only. It can have any number of records(rows). The current "Display" allows 25 rows visible. Therefore, if I have more than 25, I need to use the scrollbar.

I worked out a routine that will print the contents of the complete DataGrid. For example, if the record count = 80, I will get 4 pages of printout ( 3 pages, each showing 25 records, and a 4th page with the balance (5 records),

Problem:
The last page will not only show the last 5 records but it will show the previous 20 (20 + 5 = rows visible).

Question:
Is there any way just to show the last 5 record on the datagrid?

The Code:
' RecordCount = adoTrackSort.Recordset.RecordCount is done in a different sub routine

cdPrint.ShowPrinter
Printer.Orientation = vbPRORLandscape
If RecordCount > 25 Then
ScreenCount = Round((RecordCount / 25), 2)
ScreenCount = Round(ScreenCount)
CountDiff = RecordCount - (25 * ScreenCount)

Else
ScreenCount = 1
End If
If ScreenCount >= 1 And CountDiff > 0 Then
HoldScreenCount = ScreenCount + 1
End If
If ScreenCount >= 1 And CountDiff = 0 Then
HoldScreenCount = ScreenCount
End If
ScreenCount = 1
RowPosition = 1
Do Until (ScreenCount + 1) > HoldScreenCount
' Me.PrintForm
DoEvents
RowPosition = RowPosition + 25
ScreenCount = ScreenCount + 1
dbgTrackSort.Scroll 0, 25
DoEvents
Loop
dbgTrackSort.Scroll 0, (RecordCount - CountDiff + 1)
Me.PrintForm
DoEvents
Call MsgBox("You have " & HoldScreenCount & " Pages of printout for this report.", vbInformation, "Report Pages")

Datagrid Didnt Populate? Cant Display Anything
hi all, i am using vb6, i put a datagrid on my form to display records from my ado recordset, but my datagrid dint display/populate any records though my recordset is populated, wads causing tis? .... need help on this ... how to display records on the datagrid correctly when i return a query ? thx..



Private Sub cmdclick_Click()
Dim myconn As ADODB.Connection
Dim myrecset2 As ADODB.Recordset

Dim strnric As String
Dim strrank As String
Dim strname As String
Dim strunit As String
Dim strvoc As String

strnric = Text1.Text
strrank = Text2.Text
strname = Text3.Text
strunit = Text4.Text
strvoc = Text5.Text

Set myconn = New ADODB.Connection
myconn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:/VBWORKSPACE/TESTADO.MDB;"
myconn.Open

Set myrecset2 = myconn.Execute("INSERT INTO PERS VALUES ('" & strnric & "','" & strrank & "','" & strname & "','" & strunit & "','" & strvoc & "')")

MsgBox "Data added successfully !", , " "

myrecset2.Open "Select * from PERS", myconn, adOpenKeyset, adLockOptimistic, adCmdtxt

myrecset2.MoveFirst


Set DataGrid1.DataSource = myrecset2
DataGrid1.Refresh


myrecset2.Close


myconn.Close

End Sub

Display Fresh Data On Datagrid
Hello, I'm deleting (recordset.delete) certain rows shown through a datagrid control.When i click update (recordset.update), the datagrid doesn't show the updated record and it will load & show the updated record only when i unload and reload the form, or when the form is "reActivated". I'm trying to use "datagrid.rebind" command to refresh the datagrid,but nothing happens.I'll have to unload and load the form again to display fresh data on the datagrid, but i know there is a right way to do this.Can somebody please tell me how?

Datagrid And Extern Data Display
I've a datagrid and i want
to display Column 7 in a textbox
if row is changed

and if the textbox changes
i want to save it into the
datagrid

my datagrid is bound on a recordset

how could i do this?

Datagrid Wont Display Table
when i run the following source i get an error that says that the jet engine cant find Table. but when i look in the database the table has been created.


Quote:




Dim strSQL As String

' hieronder worden de trades die bij het CUSTUMORID van de desbetreffende klant horen, geselecteerd en
' daarna in de tabel TEMP gezet.




Text1.Text = voornaam
Text2.Text = achternaam
Text3.Text = rekeningnummer
Text5.Text = klantid

Label4.Caption = Date

Set db = OpenDatabase("C: ooltjedb1_97.mdb")
Set rs = db.OpenRecordset("Custumors", dbOpenTable)
Set rs1 = db.OpenRecordset("Account", dbOpenTable)
Set rs2 = db.OpenRecordset("AccountInitialValue", dbOpenTable)
Set rs3 = db.OpenRecordset("Trades", dbOpenTable)


db.Execute (" drop table Temp")
strSQL = "select [start price], [end price] ,[volume], [stop loss] into [Temp] from trades where volume <> 0 and CustumorID = " & klantid
db.Execute (strSQL)
db.Close


Set db = OpenDatabase("C: ooltjedb1_97.mdb")
Set rs4 = db.OpenRecordset("Temp", dbOpenTable)
rs4.Close

'datastring = "select [Reference_Nr], [soorttrade], [start price], [end price], [stop loss], [openclosed],[deposit],[withdrawl], [currency] from Trades where [CustumorID] = " & klantid

Set rs4 = db.OpenRecordset("Temp", dbOpenTable)
rs4.MoveFirst
datastring = "select volume from [Temp]"
'Data1.RecordSource = rs4.Fields("volume")
Data1.RecordSource = datastring
Data1.Refresh


Text8.Text = rs4.Fields("volume")

end sub






the thing is that text8.text does display the value from that field..

anybody can tell me why it wont display the data from Table in de datagrid

Doesn't Display Valus In Datagrid
hey,


to display a recordset in a datagrid I used the following code:


Code:
Private Sub cmdalle_Click()

adodcmaat.CommandType = 8
adodcmaat.RecordSource = "SELECT BVVO FROM Maatschappij where naam= '" & lstBVVO.Text & "'"
adodcmaat.Refresh

MsgBox "" & adodcmaat.Recordset.Fields(0)

BVVOnr = adodcmaat.Recordset.Fields(0)

connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "KBC.mdb;Persist Security Info=False"
Set con = New ADODB.Connection

con.Open (connectionstring)

sql = "SELECT Polis.agentnrintern, (sum(Resultaat.winst) - sum(Resultaat.verlies)) as wvagent" _
& " FROM Polis INNER JOIN Resultaat ON Polis.polisnrintern = Resultaat.polisnrintern" _
& " Where Resultaat.BVVO = " & BVVOnr & "" _
& " group by Polis.agentnrintern"

MsgBox "" & sql

adodcwva.CommandType = adCmdText
adodcwva.RecordSource = sql
adodcwva.Refresh

MsgBox "" & adodcwva.Recordset.Fields(0) & adodcwva.Recordset.Fields(1)

datagridwv.Visible = True
datagridwv.Refresh
txtwv.Visible = False
lblwv.Visible = False
lstagent.Enabled = False

End Sub

In the msgbox the valus are display perfectly, but they don't appear in the datagrid. I linked the datagrid via the datasource property to the recordset adodcwva. What am I doing wrong?

SQL Statement To Display Record In DataGrid
Hello guys!!!!,,,I have tried..tried..tried. but it seems I can't get what I want for my output. If I run my program it displays record in the datagrid but whrn I tried to search position in the textbox it has an error saying 'method open of object failed recordset' pointing to rs.Open sql,cn....
But if I change my sql statement with: sql = sql & " WHERE Cname LIKE '%" & Text1 & "%' order by Cname asc" it works.
My sql statement below searches position and then display the name order by totalscore in ascending order. Thank you ...I hope I make this time around...




Code:
Dim strRS As String
Dim sql As String
Dim rs As New ADODB.Recordset
Dim Cn As ADODB.Connection

Private Sub Form_Load()

Dim strConn As String
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & App.Path & "db1.mdb"

Set Cn = New ADODB.Connection
Cn.Open strConn

strRS = "SELECT * from CandidateScore order by CName asc"
Set rs = New ADODB.Recordset

rs.CursorLocation = adUseClient
rs.Open strRS, strConn, adOpenDynamic, adLockOptimistic, adCmdText

Set DataGrid1.DataSource = rs
DataGrid1.Refresh

End Sub

Private Sub Text1_Change()

sql = "SELECT * FROM CandidateScore"
If Len(Text1) <> 0 Then
sql = sql & " WHERE position LIKE '%" & Text1 & "%' order by TotalScore asc"
End If

rs.Close
rs.Open sql, Cn, adOpenDynamic, adLockOptimistic, adCmdText

Set DataGrid1.DataSource = rs

End Sub

Datagrid Date Display At Dtpicker
how to display datagrid date display at dtpicker?
example:when i click at the datagrid row data will display at textbox and dtpicker.

Private Sub DataGrid1_Click()
DataGrid1.SetFocus
DataGrid1.MarqueeStyle = dbgHighlightRow

'DTPpurchase = DataGrid1.Columns(2)
Txtidnumber.Text = DataGrid1.Columns(4)
Txtprice.Text = DataGrid1.Columns(5)
Txtstatus.Text = DataGrid1.Columns(6)
DataGrid1.Refresh
End Sub

Display Customer Information In DataGrid
using datagrids how do you get it to display for instance only the information on one customer.

Datagrid To Display Data From Two Tables
Hi,

I am trying to display data from two tables in the one datagrid using an ado data control. The first table is expenses and the second is rates and they are joined by rateid. The trouble is I wasnt to show expenses for just one employee..

Having major difficulty. Any help would be appreciated.

How Do I Use Datagrid To Display My Records In The Access DB
hi, how do i display all my record in the Access DB using a Datagrid...can anyone help me with the codes

this is my coding:

Dim SQL As String
Dim cmbRS As ADODB.Recordset
Dim Cnn As ADODB.Connection
Dim RS As ADODB.Recordset
Dim sqlstr As String

sqlstr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & App.Path & "" & DataEnteries.DBname.Text

Set Cnn = New ADODB.Connection
Cnn.Open sqlstr

SQL = "SELECT * FROM " & month.Text & ""
Set RS = New ADODB.Recordset
RS.Open SQL, Cnn, adOpenDynamic, adLockOptimistic
Set DataGrid1.DataSource = RS

got error: the rowset is not bookmarkable

Ah Xing

Datagrid Display[solved - Thanks To Rookie_student]
Finally got convinced with :

http://www.vbforums.com/showthread.p...716762#newpost


How do I get rid of the extra blank row and column displayed?
(See Attachment)

Basic DataGrid Display Outputs
Hi,

I am a complete VB novice, so please go easy.

I am trying to output the return of a stored proc I have into a DataGrid. I can get it to display in a textbox and other places, so the next logical step is to display it in a DataGrid.

I have a string which gets the data, which I use to get it into the textbox. but I am not sure how to display it into a DataGrid. I'm not bothered about fomatting or anything like that, I just want to start with the basics of getting anything into a DataGrid.

Here is all I have so far from what I could find on the web and in the useless books I have:


Code:


Set DataGrid1.DataSource = rs
DataGrid1.Visible = True


rs being my recordset (obviously)

and my string for the output is 'outTBox'

Any basic help / pointers of how to get anything into a DataGrid would be most appreciated. Even links to some "usefull" sites.

Thanks,
Mark.

Display Data From Datagrid To Textbox
i want to know on how can i simply display the data in datagrid in the textbox.for example the user will click on one item in the datagrid and then all the data from the row will be displayed in each of the textbox that i've assign for each of the fields in the recordset.help me..tq

Datagrid Doesn't Display Data
Hi there,
I tried to use a datagrid control is to display some
records retrieved from a table but couldn't get it
done.
stmt = "Select itemName, quantityAvailable from
inventory"
set rs = new recordset
rs.open stmt, activeConn,........
datagrid1.dataSource = rs
with rs
if .RecordCount > 0 then
.movefirst
end if
............
In the debugging window, I could see that 16 records
were retrieved but datagrid1 didn't display any data.
Why? And can data be displayed? Anyone has any idea?
Please help.

Jeremy

Determining Data To Display In A DataGrid (VB6)
Hi guys,
i've now got a datagrid which i need to populate with records from a mdb table depending on what is selected in two combo boxes.

I have two combo boxes which display date from and date to and i need some code that puts records into the datagrid between the two dates selected in the combo boxes....so if anyone could help out , i'd be grately appreciative.


Display Edited Datagrid Without Doing Another SQL Query
I need to be able to edit a row in a datagrid and then display the edited grid without doing another SQL query. I can get the edited row, update the database, but how do I display the "refreshed" edited grid without doing another SQL query? I included the buildgrid sub too.

Thanks!




  Public Sub UpdateCommand(ByVal source As Object, ByVal e As DataGridCommandEventArgs)

        Dim strPhoneNum As String
        Dim strIndicator As String
        Dim newUserID As String
        Dim newPassword As String
        Dim login As String = LCase(Convert.ToString(Session("login"))) 'get the windows login captured in global
        Dim strPhoneNumber As String = CType(e.Item.FindControl("addPhoneNumber"), TextBox).Text 'grab the selected column values
        Dim intPhoneNumberID As Integer = Convert.ToInt16(grdAdded.DataKeys(e.Item.ItemIndex)) 'grab the PhoneID (db primary key - grid datakeyField)

        'set the function for the log file
        Session("FunctionPerformed") = "Updated"

        grdAdded.EditItemIndex = -1


        'save editing to the database
        Try
             DoNotCall.updateNumber(strPhoneNumber, intPhoneNumberID, login)

            '???????update dataset to contain the new updated record and the previous unedited records

    'store the edited dataset
              Session("DataSource") = ds

              buildAddGrid(ds)

        Catch ex As Exception
              Throw New Exception(ex.Message)
        End Try

    End Sub

 Private Sub buildAddGrid(ByVal ds As DataSet)

        Dim strFunction As String = Convert.ToString(Session("Function"))

        'fill grid with record added
        Try
            Dim dv As New DataView

            dv = ds.Tables(0).DefaultView
           
             ' bind the columns...
            grdAdded.DataSource = dv
            grdAdded.DataBind()

        Catch ex As Exception
              Throw New Exception(ex.Message)
        End Try
      
        'show the data panel
        pnlAdd.Visible = True

    End Sub

Display Total In Datagrid Footer/last Row
hi i got a problem on how to display the total value of the records in each record from a database. i have populated the datagrid with the records from the database, but i dont know how to display the total amount in the last row of the datagrid.
please help..

Cannot Display Query Results In Datagrid
Hi,

This is probably very simple but here's what I need to happen:

A user selects a month from a combo box
Based on the month the user selects
the program searches the date field in every record of the master file
and displays ONLY those records that match the selected month in the datagrid

It's an Access database with ALL fields as TEXT.
Several textboxes and comboboxes are bound to one DATASET.

Right now, it just displays all records. As I scroll through the datagrid, the textboxes and comboboxes change arccordingly (because they're bound).

I need to know the best way to approach this.

I think there is a way to do this without having to create another dataAdapter or dataset, but I could be wrong.

I'd like to just create another OLEDBcommand and implement it , but dont know how

Here's the command I'd like to code , but this won't work:

SELECT *
FROM AppData
WHERE Date Entered = me.cboMonth.Selectedvalue

me.cboMonth contains the months January through December right now.

Any suggestions?
Bill

How To Display A Combo Box Or A Check Box In A DataGrid
Hi,

does anyone no how to convert a DataGrid cell from textfield to combo box that displays specific values when the user clicks on the cell?

From the DataGrid's property pages dialog box, I can select Layout tab, select the column I wish to change from the column combo box and then click on the Button check box. OK, this displays the combo box but it 's empty. How can I fill it with values?

How can I display a checkbox in DataGrid cell that is bound to a boolean value? I 've tried DataGrid's property pages dialog box, select Format tab, select the column I want from the combo box, click on CheckBox format type but don't see any difference.

Thanks in advance for your replies.

Best regards,

John.

Copyright Đ 2005-08 www.BigResource.com, All rights reserved