|
-
Aug 11th, 2005, 02:29 PM
#1
Thread Starter
Addicted Member
datagrid fill problem
VB Code:
Dim sqlselect As String = "select job.jobnum,job.company,job.product_a,job.storcount,job.tline,job.week " & _
"received.weight,received.boxnum,received.numberrecvd,received.comments,received.recdate,received.bay " & _
"FROM received RIGHT JOIN Job ON received.JobNum = Job.JOBNUM;"
da = New SqlCeDataAdapter(sqlselect, ceConn)
ds = New DataSet("Job")
da.Fill(ds)
DataGrid.DataSource = ds.Tables(0)
it gives me errors at the last line. my guess is that it doesnt like my query. not that the sql syntax isnt good,but it doesnt want to bind it. what is the correct way to do this? also how do i filter those records by a certain criteria. what i really want to do is not have all those records viewable, but everything that matches the result of my input box.
-
Aug 11th, 2005, 03:27 PM
#2
Thread Starter
Addicted Member
Re: datagrid fill problem
ok, what if I want to fill my grid with an sql view. can i do that? i think i found a c# example but i cant read it.
-
Aug 11th, 2005, 03:29 PM
#3
Thread Starter
Addicted Member
Re: datagrid fill problem
if i have learn soem xml so be it. i just need some sort of direction. if you read my other posts you will see that i tried a datareader,databinding to textboxes and such. now i am running low on options.
-
Aug 11th, 2005, 08:18 PM
#4
Re: datagrid fill problem
Well, if the error is on the last line, then the SQL has already worked fine. However, if you want to select rows based on values in a text box, you'll need a WHERE clause in there.
The simplest way to do that would be adding
"WHERE <somefield> = '" & textbox.text & "'"
right after the FROM clause.
Of course, it would be a bit safer to test the value in the text box to see that it is at least close to the right range, but if nothing is entered, or something bad is entered, you simply won't get any data.....unless something REALLY bad is entered, such as:
",DROP TABLE received"
That would be malicious, because your table would be deleted.
What is the error you are getting. The syntax you have looks mighty familiar. In fact, it looks like something I might have posted in response to an earlier question. If it is, then I know that it SHOULD work, because it works for me.
My usual boring signature: Nothing
 
-
Aug 11th, 2005, 08:22 PM
#5
Re: datagrid fill problem
Aha, one critical difference.
I read in a book that you need to do this:
VB Code:
dg1.Enabled = False
dg1.DataSource = ds.Tables(0)
dg1.Enabled = True
The book mentioned that enabling and disabling the datagrid made it work right. I see that I have only done it that way, and otherwise am doing the same thing that you are. Try that.
My usual boring signature: Nothing
 
-
Aug 12th, 2005, 08:12 AM
#6
Thread Starter
Addicted Member
Re: datagrid fill problem
ok this is odd. when i have my posted code with your code in the load procedure it stops at dg.enabled=false and says it cant do that. i look at the highlted line and it says dg.enabled=true. but if i have our code triggered by another procedure i get a token line error, error parsing.
-
Aug 12th, 2005, 08:17 AM
#7
Thread Starter
Addicted Member
Re: datagrid fill problem
ok i found my error. i was missing a comma at the end of my first line of my sql. hopefullly works now.
-
Aug 12th, 2005, 08:20 AM
#8
Thread Starter
Addicted Member
Re: datagrid fill problem
hooray for me. oddly enough the same code doesnt work in the load but works by trigger.
-
Aug 12th, 2005, 08:38 AM
#9
Thread Starter
Addicted Member
Re: datagrid fill problem
ok i was wrong, i forgot the connection part. i have my parameters working fine and i can search as much as i want. now how do i edit and update records? another thing, in my received table i hate a date field that i used to be able to autofill with todays date and time. this was when i used an "insert" sql command. am i still ognna be able to do that?
-
Aug 12th, 2005, 08:51 AM
#10
Thread Starter
Addicted Member
Re: datagrid fill problem
i found a site that is written in c++, it looks like what i need. could someone translate into vb?
http://www.wwwcoder.com/main/parenti...8/default.aspx
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|