Datagrid Display Incorrect Data
I'm stock when my datagrid display only check boxes instead of texts in the datagrid cells. Below are my code that I use to populate the datagrid.
Code:Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=C:VB ProjectFormPracticeLoginScholarship.mdb" Dim strPerSQL As String = "SELECT Personal.SSN, Personal.FstName, Personal.MdlName, Personal.LstName, Education.Status, Education.Rank FROM Personal, Education WHERE Personal.SSN=Education.SSN" perDataAdapter = New OleDbDataAdapter(strPerSQL, strConn) perDataSet.Clear() perDataAdapter.Fill(perDataSet, "Personal")
Dim ts As New DataGridTableStyle() dgApplicants.SetDataBinding(perDataSet, "Personal") ts.MappingName = "Personal" Dim dtColSSN As New DataGridBoolColumn() dtColSSN.HeaderText = "SSN" dtColSSN.MappingName = "SSN" dtColSSN.ReadOnly = True Dim dtColFstName As New DataGridBoolColumn() dtColFstName.HeaderText = "First Name" dtColFstName.MappingName = "FstName" dtColFstName.ReadOnly = True Dim dtColMdlName As New DataGridBoolColumn() dtColMdlName.HeaderText = "Middle Name" dtColMdlName.MappingName = "MdlName" dtColMdlName.ReadOnly = True Dim dtColLstName As New DataGridBoolColumn() dtColLstName.HeaderText = "Last Name" dtColLstName.MappingName = "LstName" dtColLstName.ReadOnly = True Dim dtColStatus As New DataGridBoolColumn() dtColStatus.HeaderText = "Standing" dtColStatus.MappingName = "Status" dtColStatus.ReadOnly = True Dim dtColRank As New DataGridBoolColumn() dtColRank.HeaderText = "Rank" dtColRank.MappingName = "Rank" ts.GridColumnStyles.Add(dtColSSN) ts.GridColumnStyles.Add(dtColFstName) ts.GridColumnStyles.Add(dtColMdlName) ts.GridColumnStyles.Add(dtColLstName) ts.GridColumnStyles.Add(dtColStatus) ts.GridColumnStyles.Add(dtColRank) dgApplicants.TableStyles.Add(ts)
dgApplicants.DataSource = perDataSet.Tables!Personal
Please help.
Thanks!
Chong
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
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 Correct Or Incorrect Answer
here is my situation:
I have a text box (text1) and I want it so that when I enter something into it it will either display correct or incorrect in a label next to it (lblAnswer)
Here is a something that might help you understand
I have a sum. Basically some has to enter the answer into a text box (text1) and either 'correct' or 'incorrect' should appear in a label (lblAnswer) once the command button (cmdOK) is pressed.
Here is the basic structure:
5 + 1
text1
lblAnswer
cmdOK
if anyone can help it would be greaty appreciated
Help~!dbgrid-it Display Incorrect Result~~
Im new to VB. Im now doing an assingment for me and facing problems now....>_<
I want to search a particular record from a table.
I serch by ID.When i click Serach button, it should display the record info in form of label.
but the result i get, it display the 1st record no matter which ID i serch for. In the DBGrid, it show all the records....
following is my code...
**********************************
Private Sub cmdMSearch_Click()
Dim pstrSQL As String
If txtMenuID.Text <> vbNullString Then
pstrSQL = "SELECT * FROM menu WHERE mID =" & txtMenuID.Text
datMenu.RecordSource = pstrSQL
dbgMenu.Refresh <===Notes***
lblAID.Caption = dbgMenu.Columns("mID")
lblADesc.Caption = dbgMenu.Columns("mDesc")
lblACat.Caption = dbgMenu.Columns("mCategory")
lblAPrice.Caption = dbgMenu.Columns("mPrice")
End If
End Sub
*************************
For the [Note***] line, i found in my text book, it wrote it as
datMenu.Refresh
When when i followed it, it got error.(so i modify myself ;p )
%%%%%%%%
For Another question....
I want to add new record into the database using textbox & Add button, how to do it?
Thx a lots ....
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 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.
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.
Incorrect Combobox Alignment Over Datagrid
I'm using a datagrid with a couple of dropdown boxes.
I had datalists before, but I'm trying to change them to combo boxes, since they serve my purpose better.
Now, the code I was using to place the datalist over the datagrid cell was a cut and paste from Microsoft, and it worked fine:
Code:
...
DataList1.Top = DataGrid1.Top + DataGrid1.RowTop(DataGrid1.Row) + DataGrid1.RowHeight
DataList1.Left = DataGrid1.Left + DataGrid1.Columns(ColIndex).Left
DataList1.Width = DataGrid1.Columns("Name").Width
DataList1.Height = 1440
DataList1.Visible = Not DataList1.Visible
If DataList1.Visible Then
DataList1.Text = DataGrid1.Text
DataList1.ZOrder
End If
...
But the problem is that if I try the same code with a combo box (without the height change of course), then the combobox appears a little to the left and about a half-cell higher than it should.
Anybody know how to fix this?
Open .csv File And Display All The Data Inside To Datagrid?
hi
what i want to do is i open .csv file and display all the data inside that .csv file to datagrid and refresh the datagrid everytime that .csv file data inside modify?
the problem i face it now display it to datagrid and refresh it?
open file it's ok for me.
thanx a lot.
Incorrect Data Reported
I have a VB 5 program that uses an Access 97 DB.
When one user runs the program from her PC it shows only some of the data. If she runs the program from another PC it shows all of the data.
The only way to fix her PC is to FORMAT C: and reinstall everything.
Can anyone explain what I can do to fix the problem???
Anyone have thoughts or experience similar problems.....
Access DB, VB Extracting Incorrect Data
I entered the following into a field in a database: 1 YEAR OR LESS $1MM/$2MM
When I read it back out of the database with my program, this is what I get: I YEAR OR LESS $1MM/$2MM
Somehow VB is changing that first 1 to a capital i. I ‘m thinking it’s a Roman Numeral 1, but I haven’t a clue as to why it would do that. Any one ever see this before? Any way around it?
Incorrect Data Stored By StdFont Type Variable
Hi All,
In my project, I have declared a variable say X as New StdFont. I am using it to store font properties like size, name, charset, etc. However, when I assign an integer as its size, it stores it the value incorrectly. For example, if I assign 5 to X.FontSize, it stores as 5.25. In order to isolate the cause of the issue, I used this data-type alone in a sample project and checked. The project has one text box (Text1) in one form. Please have a look:
Dim MyFontObj As New StdFont
Private Sub Form_Load()
For i = 1 To 15
MyFontObj.Size = i
Text1.FontSize = MyFontObj.Size
Next i
End Sub
Following is the correct and incorrect values respectively stored by MyFontObj.Size:
1 - 1.5 6 - 6 11 - 11.25
2 - 2.25 7 - 6.75 12 - 12
3 - 3 8 - 8.25 13 - 12.75
4 - 3.75 9 - 9 14 - 14.25
5 - 5.25 10 - 9.75 15 - 15
Also, I noticed that only values that are multiples of 3 are stored correctly. Rest, either 0.25 is added or reduced to the actual values.
I'm wondering whether it is property of StdFont data type.
Any suggestions???
Regards,
MrNiceGuy
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
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?
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 && 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) & "'"
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 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
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
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.
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
|