Help with data grid

K

Kimberley Wiggins

Can someone please help me? I am still learning vb so this is fairly
new.

I have been chasing this problem for 3 days now and I think that I am
ready to give up. Does anyone know how to make my data grid display on
a tab control? I have a tab control with 2 tabs on it, one for the
data grid and the other for comments. I have tried everything. Where
do I add the code to say display the data grid on this tab? I have the
code and everything working to fill the data adapter and fill the data
grid from the table but I don't know how to make it display on the tab
control. This is driving me crazy, help...thanks

this is my code for the data adapter:

Dim strOTRConnection As String = "Provider=Microsoft.Jet.OLEDB.4.0;
Data Source= C:\otr.mdb"
Dim strSQLEpisode As String
Dim dtEpisode As New DataTable
Dim dgEpisodes As New DataGrid

dtEpisode.Clear()
strSQLEpisode = "SELECT * " & _
"FROM Episode WHERE showcode = '" & Me.txtCode.Text & "' "
Dim dataAdapter As New OleDb.OleDbDataAdapter (strSQLEpisode,
strOTRConnection)
dataAdapter.Fill(dtEpisode)
dataAdapter.Dispose()
Me.dgEpisodes.DataSource = dtEpisode


As you can see, I handled everything in code so I did not build a
dataset or used any tools. Just added everything to connect the data
adapter in code.
Thanks
 
K

Ken Tucker [MVP]

Hi,

Are you sure you are getting any data into the datatable ?
Debug.Writeline(dtEpisode.Rows.Count) will tell you how many rows are being
returned.

Ken
 
K

Kimberley Wiggins

Yes I did try that and it does show that I am getting the correct rows
into the datatable.
 
C

Cor

Hi Kimberly,

It is strange becaus I tested your code (with another database) and it
showed a datagrid .

But I had nothing to add to Kens question, because mine would have been the
same.

But now my next question, is the datagrid showed (empty)?

Cor
 
K

Kimberley Wiggins

Yes, I finally got the datagrid to display but it is displaying empty.
I would think that it would just display by the code that is in the
leading tables records but I guess not. I had it to fill the data
adapter and it is pointing to the correct table. Do you know what could
be wrong?
Thanks
 
C

Cor

Hi Kimberley,

You say finaly, you are sure it is the same datagrid?
(The same name dgEpisodes)

Cor
 
K

Kimberley Wiggins

Yes you were right, I was looking at the wrong grid. It is not pulling
back any records. It is something in my select statement. When I try
this:

strSQLEpisode = "SELECT * from episode"

it pulls back all 9024 records. But when I try this:

strSQLEpisode = "SELECT * from episode" & _
"FROM Episode WHERE showcode = '" & Me.txtCode.Text & "' "

it pulls back 0. Can you see anything wrong with this statment? The
text box that it is getting the showcode column from is populating is
there is no reason why it should not drive off of that.
 
K

Ken Tucker [MVP]

Hi,

Try this.

strSQLEpisode = "SELECT * from episode" & _
"FROM Episode WHERE showcode LIKE '" & Me.txtCode.Text & "%' "

Ken
 
C

Cor

Kimberley,

No I see nothing.


strSQLEpisode = "SELECT * from episode" & _
"FROM Episode WHERE showcode = '" & Trim(Me.txtCode.Text) & "' "

But in my opinion that cannot be the error.

You are shure you fill in a good value?

Cor
 
K

Kimberley Wiggins

I found what the problem was. The text field name that is driving what
will display in the data grid keep having a record that I entered
through my add code. I now need to figure out why that is the record it
is always going back to when I start the program instead of back to the
beginning of the file. Thanks
 
C

CJ Taylor

Ken Tucker said:
Hi,

Try this.

strSQLEpisode = "SELECT * from episode" & _
"FROM Episode WHERE showcode LIKE '" & Me.txtCode.Text & "%' "

^^ Perhaps a space after the episode or before the from would help?

-CJ
 
M

meh

Hi all;

Sorry if I've missed something....I'm coming into this late.....but....

Sould I assume that episode and Episode are 2 different tables in this
database????

meh
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top