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.
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.
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.
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.
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.
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.
Re: datagrid fill problem
hooray for me. oddly enough the same code doesnt work in the load but works by trigger.
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?
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