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




Fill Datagrid With Sql Query


Hi,
i have a database with fields likename,address etc... i want to insert a datagrid to the form that shows some data that come from an sql query. But for the sql query to work i need a textbox value that is on the form. I inserted an adodc but if i put on the recordset,in adodc properties "...name LIKE '%text3%' it tries to find a name similar to text3 what should i do?

thanks




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Won't Fill Datagrid
hi,
I'm having a trouble with filling my datagrid. Everything works perfect, but the grid isn't filled at the end of the code...


Code:
connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=KBC.mdb;Persist Security Info=False"
Set con = New adoDB.Connection
con.Open (connectionstring)

sql = "SELECT Maatschappij.naam, Agentennummer.agentnrintern, Polisnummer.polisnrintern, Claim_definitief.datum, Claim_definitief.debet, Claim_definitief.credit" _
& " FROM Polisnummer INNER JOIN (Agentennummer INNER JOIN (Maatschappij INNER JOIN Claim_definitief ON Maatschappij.BVVO = Claim_definitief.BVVO) ON Agentennummer.agentnrextern = Claim_definitief.agentnrextern) ON Polisnummer.polisnrextern = Claim_definitief.polisnrextern" _
& " WHERE Maatschappij.naam= '" & BVVO & "' and Agentennummer.agentnrintern= '" & agent & "' and Claim_definitief.status=0"

Set rec = New adoDB.Recordset

rec.Open sql, con, adOpenKeyset, adLockOptimistic, adCmdText

datagridoverzicht.Visible = True
lblwv.Visible = False
txtwv.Visible = False

Set datagridoverzicht.DataSource = rec
datagridoverzicht.Refresh

sql en rec are doing perfectly...

Fill Listbox/datalist Using Result From SQL Query, Then Use Listbox To Fill A 2nd Listbox
Need some code that will fill a listbox or a datalist with the result of a SQL query
(the result will really just be many single fields ie. EMP00001, EMP00002, EMP00003 etc. and I need these passed one by one to the listbox/datalist).


Also, when they have been instantiated, I will need the current (hightlighted) item in the listbox at the time to be used
to populate a second listbox/datalist <----- Assuming another SQL query will be necessary?


Can anyone help with the code for this?


And which is better to use for this purpose - a listbox or datalist?

How Can I Fill Dynamically A Datagrid?
Hi,
I made a program that reads data from an excel file using an sql statement (SELECT * FROM [sheet1$])
I have a Datagrid in the form and I do the following:

Set Datagrid1.Datasource=rs
rs is a recordset

How can I see the data on the Datagrid?Do I have to use a loop or something to fill the datagrid, or is there an easier and faster way?

I would appreciate an answer!

Thank you,
Thodoris

Fill Datagrid Via SQL (Access DB)
Hello,


after more than 1 year not having worked with VB 6, it seems that I have lost some knowledge...

I'm trying to fill a datagrid with data that I've retrieved from an Access DB with a SQL qtatement. Though, the thing is not working as the data is not displayed in the datagrid. The SQL is ok, I've checked it in Access...

When I want to run the program I get the message: "[ADODC] no recordsource specified. [ado] Command text was not set for the command object"

Anyone? (probably it is something stupid...)

code:

Private Sub comboCom_Click()
Dim rs As New adoDB.Recordset, sql As String

t = 0

'connection to database
con = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "Verkiezingen.mdb;Persist Security Info=False"

'Query for data
sql = "SELECT LijstID, KandidaatNummer, KandidaatNaam, NaamStemmen FROM Kandidaten WHERE LijstID LIKE '" & comboCom.Text & "*' ORDER BY LijstID ASC, KandidaatNummer ASC"

'Connect to database and retrieve data
rs.Open sql, con, adOpenKeyset, adLockOptimistic, adCmdTex

'Load flexgrid with data
If Not rs.EOF Then

rs.MoveFirst

While Not rs.EOF

With adodcLoad
.ConnectionString = con
Set .Recordset = rs
adodcLoad.Refresh
End With

Set datagridCandidates.DataSource = adodcLoad
datagridCandidates.Refresh

rs.MoveNext
Wend
End If

frmElection.Height = 7320
frmElection.Width = 8520
rs.Close
Set rs = Nothing
End Sub

How To Fill The Datagrid With Date?
I'm creating a simple payroll having problem with filling range in datagrid.
i want to fill the colunm(Date) with the range defends on DTPicker1 beginnning date and DTPicker2 ending date. and if possible the saturday and sunday is not included.

sample output:

DTPicker1 = 01/02/2006
DTPicker2 = 01/13/2006

DATE Range

01/02/2006
01/03/2006
01/04/2006
01/05/2006
01/06/2006
01/09/2006
01/10/2006
01/11/2006
01/12/2006
01/13/2006


Thanks in advance.

How To Manually Fill A Datagrid
Please help! i need a grid/table with 2 columns that will be populated by two separate arrays. I am trying to use the DataGrid control but i can't seem to populate it in code.
This is part of my code:

  Code: For i = 0 To UBound(modGlobal.strIncorrectNames)
    Code: DataGrid1.col = 0
    Code:DataGrid1.Row = i
    Code:DataGrid1.Text = strIncorrectNames(i)
Code:Next i

But when it gets to the line where I set the row (line 3), it throws this error:
"Runtime error 7005 - Rowset not available"

Any information is appreciated
Thank You

How To Fill A Datagrid With 2 Connections
Look,

I tried to fill my datagrid with a query but when i want to update it gives the error:

Insufficent key column when updating or refreshing...

I have an INNER JOIN in my query and relationships with each have priamry keys that are the same (GroupID). I have read other posts but none are too clear on how to fix this problem. I guess VB is getting confused on which field to update. If you have any idea how to fix this I would love to know. However, this is what I'm trying to do now.

I have added two ADODC connection: each one grabs the appropriate fields from their respective tables. Now I need to fill the DataGrid with all of it. ----> if this is possible

This is how I have it working right now:
the DataGrid is filled with ADODC1 and the Textboxes are filled with ADODC2....

I have a Next and Previous buttons that navigate through the Grid and textboxes (great) but when I select a row in the Grid, the text box info does not follow accordingly(of course)

How do I do this?

Answering any of these questions would be great.

rbgerman

Auto Query Fill In???
I've got a selectionquery on which i made a word document. so when i open the word document I get the query question (for easy choosing the person i want to sent it to) but since my database has become large i added a button which automatically opens the worddocument.

Now i want the queryquestion automatically filled in with the name of the person in the currently opened Record.
can anyone help me????
This is the code i got so far:

Private Sub Knop82_Click()
On Error GoTo Err_Knop82_Click

Dim oApp As Object
Dim odoc As Object

Set oApp = CreateObject("Word.Application")
Set odoc = oApp.documents.Open(Filename:="filename")

oApp.Visible = True

Exit_Knop82_Click:
Exit Sub

Err_Knop82_Click:
MsgBox Err.Description
Resume Exit_Knop82_Click

End Sub

Fill Combobox With Query
I have filled the values of my combo box with a query from an access database, and have been unable to figure out how to let the combo box allow other values typed in. If it is not included in the query, I cannot type the value in. I have played around with the properties with no luck.

How To Fill Datagrid Wiht Ado Recordset
I have a recordset(rsArticle) wiht some informaion and would like to fill all datagrid
columns with the recordset(rsArticle) then to edit the 2de column(ArticleDescription) in datagrid with a new
data.
Here is my code:
Set rsArticle = New ADODB.Recordset
Set rsArticle = objArticle.GetArticlesF(ArticleID)
Do Until rsArticle.EOF
with datagrid1
.column(1).text=rsArticle("ArticleID")
.column(2).text=rsArticle("ArticleType")
.column(3).text=rsArticle("ArticleDescription")
end with
rsArticle.MoveNext
Loop
rsArticle.close
Set rsArticle = Nothing

Fill A Datagrid From An Access Table
I'm using much of the same code as in my other thread but this time the connection is to an Access database and I'm trying to fill a datagrid.

http://www.tek-tips.com/viewthread.cfm?qid=1197203&page=1

I am not getting any errors but the datagrid isn't filling in.

Module:
CODEConst g_strConnA = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:DataMyData.mdb;"

Public g_oRs As ADODB.Recordset
Public g_oCnn As ADODB.Connection

Public Function GetCallJobs(ByVal SiteID As String) As ADODB.Recordset
    
    Dim oCmd As ADODB.Command
    Dim iRetryCount As Long
    iRetryCount = 0
    
    Set g_oCnn = CreateObject("ADODB.Connection")
    g_oCnn.ConnectionString = g_strConnA
    g_oCnn.CursorLocation = adUseClient
    g_oCnn.CommandTimeout = 0
    g_oCnn.Open
    
    Set oCmd = New ADODB.Command
    oCmd.CommandType = adCmdStoredProc
    oCmd.ActiveConnection = g_oCnn
    oCmd.Parameters.Append oCmd.CreateParameter("@SITE_ID", adVarChar, adParamInput, 15, SiteID)
    oCmd.CommandText = "qryJobsBySite"
    
    Set RS = CreateObject("ADODB.Recordset")
    Set RS.ActiveConnection = g_oCnn
    RS.CursorLocation = adUseClient
    Call RS.Open(oCmd, , adOpenStatic, adLockBatchOptimistic)
    
    Set RS.ActiveConnection = Nothing
    Set GetCallJobs = RS
    Set RS = Nothing 'i tried commenting this out
    g_oCnn.Close
    Set g_oCnn = Nothing
    
End Function

Populating DataComboBox's And Fill DataGrid
On my form, I'm trying to populate a second DataComboBox from the selection of the first DataComboBox.

Then select from the second DataComboBox and have the third DataComboBox populated.

Finally once I select from the third DataComboBox a DataGrid will be filled in with the results.

I found Deke's reply to post (#4691) to be helpful. I'm a little confused now, could someone point me in a direction.

I have been using BIBI.mdb as a example.

Thanks in advance,
Mike "the Rat"

How To Fill A List Box With The Result Of A Query
Hi gurus
I want to bind a list box to the results of a query to an access databse table. I am very new in VB programming and I read about the DAO and the ADO methods.
This is the steps I did in my work:
- I created a data environnement and mad a connection to my access database (an employee database) through a jet OLE DB provider, then I selected the employee table as a source then I added a command (as query) under the same connection and made the SQL statement to habe the query, up to now everything is fine and I can see the results of my query.
- Now returning to my form where I have the listbox I filled the following properties of the list box:
- Data source - I selected the proper data environement where I have my connection to access databse
- data member - I selected the command query
- data field : the field resulting from the query

When I run the form nothing happened
Is something wrong in my way to do.?
AM I using the DAO ot ADO method like this way
thank's a lot for any help

Fill An Unbound Datagrid (or Plain Grid)
I'm a self-taught VB programmer, out of necessity. I don't like to use persistent connections to a database, and therefore use unbound controls. It's been fairly successful. HOWEVER...

How would I load a grid from a recordset without being connected via a dataenvironment? I want to load the grid and navigate it without a connection to a recordset. Kinda like loading a listbox or combobox. Once loaded, I can pull the unique key from the selected row for use in various outlandish ways.

I thought it would be as simple as "DataGrid1.AddItem" (or "Grid1.AddItem"). Nope. I'm sure it's a relatively simple thing to do, but I'm stumped. It must be Friday...

Randy

Fill DataGrid W/select Items From Database.
Can someone please give me a little code sample of how to add an item to a DataGrid using code with ADO Reference. I'm trying to add data to the grid from another form by using the "click event" and pulling the data from a database, based on the item that was clicked.
For example: Click on a red ball (on a separate form) and it gets the information from the database and adds it to the DataGrid with all of the information in the record from the database. (description, price, & etc.) I also need to have a formula to total one or two columns at the bottom. Like total quantity, and total (price).
It's kinda like a POS thing I guess, but not too complicated.
Hope I'm not asking too much here.

How To Fill Datagrid With Selected Access Table
Hi All,
I'm new to VB.Net and I have a problem accessing selected data in an access db. I keep getting the whole table entries in the datagrid, instead of the results of me SQL select.
Can anybody help me.

Thanks
George

How Do I Fill Up A Datagrid With A Recordset Real Fast?
How can I fill up a datagrid with a recordset the fastest way?

Thanks,
TheMuppeteer.


Fill Text Boxes With Datagrid Selection
I'm probably going about this the wrong way but I have a datagrid that is filled from an Access table.

When the user selects a record in the datagrid, I need some text boxes to fill in with the fields from the datagrid using a stored procedure.

I think the problem is in my parameter.

oCmd.Parameters.Append oCmd.CreateParameter("@StudentNum", adVarChar, adParamInputOutput, 255, "StudentNumber")

I'm not sure how the stored proc knows that "StudentNumber" is the value from my datagrid.

CODEPrivate Sub dgRecords_click()
    Dim SelectionCount As Integer
    Dim oAdoRset As New ADODB.Recordset
    Dim i As Integer
     
    Screen.MousePointer = 11
    SelectionCount = 0
    SelectionCount = dgRecords.SelBookmarks.Count
        
    If (SelectionCount <> 0) Then
       Call modDBSQL.GetRecord(oAdoRset)
       If (oAdoRset.AbsolutePosition <> -1) Then
            For i = 0 To 5
                'Populate the applicable text box
                txtStudentRecords(i).Text = oAdoRset.Fields(i).Value
            Next i
       End If
    Else
        MsgBox "Use the record selectors to select ONLY ONE RECORD at a time to view.", vbExclamation + vbOKOnly
    End If
    Screen.MousePointer = 0
    
End Sub

Fill Datagrid With 1 Sql Statement With Info From 2 Tables
Here is the situation.

I have
TABLE1 with field Field1, Field2
TABLE2 with field FieldA, FieldB

I want to make a select in both tables to fill a datagrid. The datagrid will have 2 column: Status and Nb

In column Status i want values of field ( Field1 and FieldA ) which contains same type of value both in 2 different tables.
In column Nb i want a count of field ( Field2 and FieldB ) ........

Separately it would be
"SELECT COUNT(*) AS NB, FIELDA as Status From TABLE1 GROUP BY FIELDA"
"SELECT COUNT(*) AS NB, FIELD1 as Status From TABLE2 GROUP BY FIELD1"


How to get the same result but in only 1 sql statement ? hope its clear enough



Edited by - Shandy on 4/22/2004 8:58:28 PM

How Can I Do A Query And Then Fill The Grid VB 6.0 In Parts Or By Block .
Hi,

How can I do a query and then fill the grid VB 6.0 in parts or by block .


thank

How Can I Do A Query And Then Fill The Grid VB 6.0 In Parts Or By Block .
Hi,

How can I do a query and then fill the grid VB 6.0 in parts or by block .


thank

Fill Up Listbox/Datalist With The Result Of A Query
Does anyone know how can I fill up a listbox or a datalist with the result of this Query :

Ssql = "SELECT Titre FROM collvid WHERE Titre like '" & texte & "%'"

Thx for any help

PHil

How To Fill Combo With Query Results In Faster Way?
hi,
can any one help me to find a solution to fill combo box fastly with query results.

How To Fill Combo With Query Results In Faster Way?
hi,
 can any one help me to how to fill combo with query results in faster way? with out looping the record set.thanx in adv.

Automatically Fill Listview/datagrid With Recordset Results
Is there any way to automatically fill a listview or datagrid with the information retrieved from a ado recordset?

Basically, after the recordset.open " select......"

the information that this recordset retrieves, should automatically fill the listview or datagrid without specifying  recordset!field1,recordset!field2 etc.

Any help would be appreciated


How Can I Fill The Email Body Message With Records From A Query
Hi,

I have the following situation in MS Access:
I need to send a set of emails (currently I'm using SendObject) with info that will be selected by a query but I need that the info appears in the body of the email and not as an attachment of the mail.
Can anyone give me a helping hand with this.

Ah! One other thing in my tests when I send an email a window appears asking if I'm sure I want to send the mail. Well this is not a good thing because if I need to send 50 emails there will be needed 50 clicks to complete the operation. Is there any way I can turn this off and send the email automatically?

Thanks in advance.

Cheers,
Paulo

DataGrid && ADO -- Why More Than One Datagrid Is Populated With One Query???
Hi,

I have an SStabbed GUI with a datagrid on each tab. I also have ONE ADO connection common to all (i.e. on the main form and not on a particular tab). My problem is that when I run a query to populate a datagrid on one tab, the other datagrids on another tab also gets populated with the same results.

The code is as follows:

    With Adodc1
            .RecordSource = "select * from PalletView where PalletNo=" & txtPalletNo.Text
            .Refresh
    End With
            
    Set dgdPallet.DataSource = Adodc1

For each different query on a tab, all I do is replace the 'dgdPallet' name with another datagrids name.

Any help would be much appreciated.

Thanks, Ash

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

                                    **** KNOWLEDGE IS LIMITLESS ! ****
    **** FOR EVERY KNOWLEDGEABLE, THERE EXISTS A MORE KNOWLEDGEABLE ! ****

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Fill Listview Then Double Click To Fill Text Boxes (Resolved)
Hello

I have been working on this project off and on for about 6 months. What I am trying to do is use a text box search and fill a list view with the results. Then select the one I want and have it populate some text boxes on another form. all the fields can contain alpha numeric characters. I have attached the program. If any one can help me it would be greatly appreciated. I have been trying various combinations but have had no success.

Thanks
Bob



Edited by - Bob Taylor on 7/29/2003 4:08:49 PM

Trying To Fill Up A Felx Grid. But It Wont Fill
Hi im trying to write some code for a flex grid to display the ContactMethod and then Contact information.
they come from different tables.
but i have a nice sql for it and it wont fill in at all. it just displays blank boxes every time.

i have on my form load to call in this order
FormatGridBefore
FillGrid
FormatGridAfter

heres the codes:

Private Sub FillGrid()
strsql = "SELECT tblALLcommunication.CommMethod, tblEMPLOYEEcontact.Connection FROM tblALLcommunication INNER JOIN tblEMPLOYEEcontact ON tblALLcommunication.CommID = tblEMPLOYEEcontact.CommID"
Set rs2 = New ADODB.Recordset
rs2.Open strsql, cn, adOpenKeyset, adLockOptimistic, adCmdText
Set flexcontacts.DataSource = rs2
flexcontacts.Refresh
rs2.Close
Set rs2 = Nothing
End Sub

Public Sub FormatGridAfter()
With flexcontacts
.ColWidth(0) = 1520
.ColWidth(1) = 1520
.ColWidth(2) = 3037
End With
End Sub

Public Sub FormatGridBefore()
flexcontacts.FixedCols = 0
End Sub

Datagrid And Query On Db
hi friends,
i got a situation where i think theres no issue but i decided to ask anyway for any ideas

here's my situation :
i got one table to confirm some delevery dates, in that table i got to confirm the delevery for two different pieces (cylinder and power unit), sometimes i only need to confirm one (either cylindre or power unit) so i decided to create a grid (datagrid) base on a query with both fields (witch i dont always need).

Now what i would like is that the grid could be based on two querys (one for cylinders, one for power unit) with only one field called delevery date
i don't think this could be possible with out having 2 grids, but i would like it in 1... can this be possible

regards
Laurent

I'll be among the best soon, very soon!!!

Query Datagrid
Hey i was just how to do this ...
I have a database table that has three fields

1.ProductId
2.Description
3.Price

I can load all of that databse into the datagrid ... but i want to be able to type a ProductId into the first datagrid column and then get the data from the other fields and put them into the other columns. So pretty much perform a query..

Anyideas cheers

Datagrid Query
hi
Is there a way to manipulate a datagrid such that when you click on a field that field will have a click event behind which you can write code?What properties do i use?

F not is there an alternative,looping through a recordset is not really working for me .

Thanks

Datagrid Query
When I have linked to a database (access) and want to display the information into a datagrid, it sorts the columns alphabetically, not the way the original database has.

Im needing to display certain columns first (Name for instance), how can I achieve this?

Combo And Datagrid Query
Hello,

I am using VB6 and Access. I have a datagrid on a form with a combo box.

The idea is that i want to select a name from the combo box and in turn populate the grid with data related to the name. So if I select PETER then I want to display any info against his name.

My query is called qryassigned and the field where the names are is called job assigned to.

When i select a name from the combo I get the following error:

Run time error 3001 - arguments are of the wrong type or are in conflict with one and other.

Thanks in advance.

Here is some code:

Code:
Dim WithEvents adoPrimaryRS As Recordset
Dim WithEvents adoPrimaryRS2 As Recordset
Dim WithEvents adoPrimaryRS3 As Recordset

Private Sub Combo1_Click()
Set adoPrimaryRS3 = New Recordset

adoPrimaryRS3.Open "SELECT * FROM qryassigned " & "WHERE job assigned to = " & "'" & Combo1.Text & "'", db, OpenStatic

Set grdDataGrid.DataSource = Nothing
adoPrimaryRS3.Requery
Set grdDataGrid.DataSource = adoPrimaryRS3

End Sub

Private Sub Form_Load()
Dim db As Connection
Set db = New Connection
db.CursorLocation = adUseClient
db.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=D:griddb1.mdb;"

Set adoPrimaryRS = New Recordset
Set adoPrimaryRS2 = New Recordset

'adoPrimaryRS.Open "select * from qrynotassigned", db, adOpenStatic, adLockOptimistic

adoPrimaryRS2.Open "select [username]from tblusername", db, adOpenStatic, adLockOptimistic

Do While Not adoPrimaryRS2.EOF
Combo1.AddItem "" & adoPrimaryRS2![username]
adoPrimaryRS2.MoveNext
Loop
adoPrimaryRS2.MoveFirst
db.Close

End Sub
Private Sub cmdRefresh_Click()
'This is only needed for multi user apps
On Error GoTo RefreshErr
Set grdDataGrid.DataSource = Nothing
adoPrimaryRS.Requery
Set grdDataGrid.DataSource = adoPrimaryRS
Exit Sub
RefreshErr:
MsgBox Err.Description
End Sub
Private Sub cmdClose_Click()
Unload Me
End Sub

Refresh DataGrid After Query
Hi

I'm looking to add a record to a table and then refresh a datagrid at the same time. I'm using Dataenvironment. This code works fine first time round:

Zeus.qryBatch (intTicket)
Me.grdBasket.ReBind
Me.grdBasket.Refresh

Second Time round it gives me the Following error:

"Operation not allowed when Object is open"

I tried Zeus.rsqryBatch.requery but it gives me the following error SQL Server Error:

"Count Field incorrect or syntax error"


Any Ideas?

Show The Query On A Datagrid
I can show a table of a database file on datagrid control (I have used an ado data control to connect database).
But I have created a query with a long sql command on MS Access.
How can I show that query on a datagrid on my VB project?

Query On A Recordset Or Datagrid
Is there a way to do a query on a recordset or a datagrid? Lets say I have a recordset but it is disconnected from the database. So now I want to query the recordset itself and see if a certain record exist. Or do I have to do some kind of for loop and do my own comparisons until I find the record?

Query The Data In A Datagrid?? Help.
Hello everyone,

Okay, so I have ADODC and Datagrid. The table content is being displayed in the datagrid in a disconnected mode.

What I want to do is have a combobox with a list of the column names so that user can SORT the data whichever they like. I want to do this by not having to send a new query to the SQL Server, because that is slow. Is it possible?

In other words, I want the user to be able to SORT and RE-SORT the data that is being shown on the datagrid (as many times as they like), without sending a new query to the SQL Server.

So I want to be able to do something like:
"SELECT * FROM datagrid1.something ORDER BY colname"

Please post any thoughts or ideas, or anything at all. Thanks a lot.

Martin

Datagrid Cell Query
Is there a way to examine a datagrid cell upon Change for specific text?

In other words, the user modifies the data in a Datagrid cell, and the code examines the cell to see if the new text is a specific string.

How To Format Datagrid With SQL Query
Hi,

Im making a datagrid output with patients who have been helped.

So the question is how to let the helped people only shown in the datagrid and not al the patients.

Tnx TanTrazz

Vb Datagrid With Access Query
i've a project and i need to view a query table using datagrid in vb

but when i try doing so
i cant see the query in the properties of the adodc (recordsource)
and when i put in the query name
i get this error message 'Undefined function 'nz' in expression'
i tried some solutions i found on the net, saying that i should change the Null to IsNull
but it does help, the problem exists

any1 kind enough to help me solve my problem ?
i have made an attachment of my project..
the query that i wish to load is either 'quePresentPercentage' or 'queAttendance_Crosstab'



Edited by - Asakura on 4/14/2005 3:20:54 AM

How Can I Update My Datagrid After I Run A Query PLEASE HELP
Can someone please help me?

I have a datagride and can update it with ease if the whole access table is shown in my datagrid.

But if I run a query that selects say 3 columns from my table then when I go to update my connection errors out.

Is there anyway I can fix this? Some one said something before about Data binding , not sure if it would help or exactly how to do it.

The code is as follows:

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        dt.Clear()
        Dim sqlstr As String

        sqlstr = "select * from USD" <------- when I run this and then update ..it updates fine

        Me.OleDbConnection1.Open()
        Me.OleDbDataAdapter1.SelectCommand = New OleDb.OleDbCommand(sqlstr, Me.OleDbConnection1)
        Me.OleDbDataAdapter1.SelectCommand.ExecuteNonQuery()
        Me.OleDbConnection1.Close()

        OleDbDataAdapter1.Fill(dt)
        DataGrid1.DataSource = dt

----------------------------------------------


 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Select Case True
            Case TextBox1.Text = ""
                MsgBox("Please Enter a Song Name")
                TextBox1.Focus()
            Case Else




                dt.Clear()
                Dim sqlstr As String


  sqlstr = "select Song, Artist, Location, Note_To_DJ from USD where Song = '" & Me.TextBox1.Text & "' " <-- but when I run- this and then try to update it errors out.

                Me.OleDbConnection1.Open()
                Me.OleDbDataAdapter1.SelectCommand = New OleDb.OleDbCommand(sqlstr, Me.OleDbConnection1)
                Me.OleDbDataAdapter1.SelectCommand.ExecuteNonQuery()
                Me.OleDbConnection1.Close()


                Me.OleDbDataAdapter1.Fill(dt)
                Me.DataGrid1.DataSource = dt




        End Select


-----------------------below is my update code....CAN SOME PLEEEASE HELP???

 Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim sqlstr As String

        If MsgBox("Warning you are about to change the database", MsgBoxStyle.OKCancel) = MsgBoxResult.OK Then
            Me.OleDbDataAdapter1.Update(Me.DataGrid1.DataSource)
            dt.Clear()
            Me.OleDbDataAdapter1.Fill(dt)
            Me.DataGrid1.DataSource = dt

            MsgBox("Update Successful")


        Else
        End If

DataGrid Edit From Query
Hi
I have a datagrid whose datasource is a SQL query.
The infromation is displayed in the grid OK. When i click
on a cell to edit it i can change the value but when i click
on another cell i get the following message:-


'insufficient base table information for updating
or refreshing'

When i have the datasource as a single table i can
edit and update cells fine.

Can anyone point me in the right direction


I am totally screwed for one whole day, Please someone help.

Dsiplay Query Or Table Without Datagrid
I'm trying to display an Access table on a vb form so that users can edit data directly in the Access table. I've done this before with a datagrid but would like to know if there's a way to somehow link a table directly without having to use a grid. I need to enable the users to paste multiple records into the table and I'm stuck on how this can be accompished with a datagrid so I'm hoping there's a way to link the table instead.
Thanks in advance for any info that could help me

Sql Select Query Results In A Datagrid
I want my search results from my SQL query to appear in a datagrid, why is it that I can find no examples? I dont want to use a flexgrid because the rest of my program is in datagrids and it will look out of place.
The code below is what im using and my grid is still empty:

frmSearch
Public strCriteria As String 'read in from input box on different form
Public strField As String 'the column name selected by the user

Private Sub Form_Load()

Dim srs As Recordset
Dim ssql As String
Set dgSearch.DataSource = srs 'dgSearch is the grid
ssql = "SELECT * FROM Members WHERE " + Format(strField) + " = '" + Format(strCriteria) + "'"
Set srs = frmMainForm.db.OpenRecordset(ssql, dbOpenDynaset)
srs.FindFirst (strField + " = '" + strCriteria + "'")
If srs.NoMatch Then

MsgBox "There are no " + strField + "s that match " & "'" + strCriteria + "'", vbOKOnly, "No Match"

Else
MsgBox frmMainForm.rs(strField).Value, vbOKOnly, "Woohoo"

End If

End Sub

It works if the value is not in the database, but if it is it just states the first value in the database and not the one that was actually searched for.
I basically want it so that if there are 3 smiths they all appear in the grid and the user can determine which one they want based on the other columns ie. first name, address.

Any help would be great, I'm sure its simple but I'm tired.

&lt;help&gt;Populate A DataGrid Control By SQL Query ??
Hi Guys,

I'm wondering on how to put a Result of a Query from an Access Table into a DataGrid Control?
Here's attached a simple project I would someone help me to get rid of this.

Many Thanks,
Habibalby

Trying To Do Datagrid Binding With A Complex Query
I am getting this error:


Quote:




An unhandled exception of type 'System.InvalidOperationException' occurred in system.windows.forms.dll






Thanks in advance for any help.
this is my code:


Code:
varAccountID = lblAccountID.Text
'fills demos dataset
Dim selectCMD As SqlCommand = New SqlCommand("SELECT q.question_id, q.short_form, '' FROM question AS q INNER JOIN question_set AS qs ON q.question_id=qs.question_id WHERE qs.affinity_id=1 AND q.question_id NOT IN (SELECT v.question_id FROM answer_heading AS h INNER JOIN answer_value AS v ON h.answer_id=v.answer_id WHERE h.account_id = '" & varAccountID & "')UNION SELECT q.question_id, q.short_form, v.response FROM answer_heading AS h INNER JOIN answer_value AS v ON h.answer_id=v.answer_id INNER JOIN question AS q ON v.question_id=q.question_id WHERE(h.account_id = '" & varAccountID & "')ORDER BY q.question_id", SqlConnection1)
Dim daAnswers As SqlDataAdapter = New SqlDataAdapter
daAnswers.SelectCommand = selectCMD

SqlConnection1.Open()

Dim DsAnswers1 As DataSet = New DataSet
DataGrid1.DataSource = DsAnswers1

DsAnswers1.Clear()
daAnswers.Fill(DsAnswers1)

SqlConnection1.Close()

How Do You Put Query Results Into A Datagrid Or Table?
How do I put the results of my query using ADO into a table or datagrid. The way I have it now is that it just prints to a richtextbox...

OO4O - Getting Query Results Into A Datagrid
Hello everyone!

This is my first message so maybe a short intro is appropriated.
My name is Robin, I'm working as oracle dba / system- and networkadmin.
I also do some VB programming. I joined VB.ittoolbox in order toimprove my
VB skills, and offcourse to help others out.

Back to the facts:

Currently I'm working on an application that retrieves data using oo4o
(Oracle Objects for OLE).
I managed to connect and query the database, but now I want to put my
recordset into a datagrid.
With an ADO connection I know how to handle this. Just set thedatasource of
the grid to the ado connection.
I already experimented with "datasourcebehaviour = 1" but I cantfigure out
how it works.

Can anyone help me with this?



Thanks in advance,



Robin



Gemeente Veendam


Bezoekadres:


Raadhuisplein 5


9641 AW Veendam



Postbus 20004


9640 PA Veendam


Telefoon: 0598-652222


Fax: 0598-652250



De informatie in deze e-mail is vertrouwelijk en uitsluitend bestemdvoor de
geadresseerde. Indien de lezer van deze mededeling niet degeadresseerde is,
wordt u er hierbij op gewezen, dat u geen recht hebt kennis te nemenvan de
rest van deze e-mail, het kopi=EBren of te verstrekken aan anderepersonen dan
de geadresseerde. Indien u deze e-mail abusievelijk hebt ontvangen,brengt u
dan de afzender op de hoogte waarbij u gevraagd zal worden hetoriginele
bericht te vernietigen. De Gemeente Veendam is niet verantwoordelijk en
wijst iedere aansprakelijkheid af voor en/of in verband met allegevolgen
en/of schade van een juiste en volledige verzending en ontvangst van de
inhoud van deze e-mail.

The information in this e-mail is confidential and intended solely forthe
person to whom it is addressed. If this message is not addressed toyou,
please be aware that you have no authorization to read the rest of this
e-mail, to copy it or to furnish it to any person other than theaddressee.
Should you have received this e-mail by mistake, please bring this tothe
attention of the sender, after which you are kindly requested todestroy the
original message. The Gemeente Veendam cannot be held responsible orliable
in any way whatsoever for and/or in connection with any consequensesand/or
damage resulting from the proper and complete dispatch and receipt ofthe
content of this e-mail.

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