September 15, 2008 at 9:52 am
In C#, I create a new table in my SQL Express database (SELECT * INTO Enroller.dbo.tempEmp FROM Enroller.dbo.tlkpEmployees). I can see, through Studio Express, that the table is created correctly and it contains the data rows I am expecting. However, my subsequent "if (l_rsData.Tables[0].Rows.Count > 0) " statement throws an IndexOutOfRange exception - {System.SystemException} {"Cannot find table 0".}. Why am I not able to access the new table even though it appears to have been created and populated correctly? I have also run into this same problem when trying to use a temp table.
l_sSQL = "SELECT * INTO Enroller.dbo.tempEmp FROM Enroller.dbo.tlkpEmployees WHERE ";
l_sSQL = l_sSQL + "ID = '" + l_sCloneFrom + "' ";
cData = new ElecEnrol.Classes.cSQL();
l_rsData = cData.cDataSet(l_sSQL);
cData = null;
if (l_rsData.Tables[0].Rows.Count > 0)
September 15, 2008 at 10:01 am
HI there,
Does you c# connection have permissions to this new table?
Also what is the select statement you wrote ?
thanks
Chris
----------------------------------------------
Try to learn something about everything and everything about something. - Thomas Henry Huxley
:w00t:
Posting Best Practices[/url]
Numbers / Tally Tables[/url]
September 15, 2008 at 10:11 am
Hi Chris.
My Select statement in my C# application is:
SELECT * INTO Enroller.dbo.tempEmp FROM Enroller.dbo.tlkpEmployees WHERE ID = 'SNK20080912_1'
And, yes, I have access to the database. I am able to INSERT, UPDATE, etc. programmatically, with this same connection string, to any existing table in the database; however, for whatever reason, I cannot access the new table that I just created, in the same database. Any ideas?
Thanks.
September 15, 2008 at 10:14 am
Can you do a simple select from this table using your c# connection?
Also can you do a simple selecting in SSMS?
thanks
Chris
----------------------------------------------
Try to learn something about everything and everything about something. - Thomas Henry Huxley
:w00t:
Posting Best Practices[/url]
Numbers / Tally Tables[/url]
September 15, 2008 at 10:20 am
I can do a simple SELECT from the new table through SSMS; however, through my C# application, I cannot even find the table, even though I can see it through SSMS.
September 15, 2008 at 10:22 am
What do you mean you can't find?
What happens when you set up a connection using the same user as you used in your SSMS connection window, and run "SELECT * FROM MyNewTable"
What is the error?
Cause this sounds like a permission problem
----------------------------------------------
Try to learn something about everything and everything about something. - Thomas Henry Huxley
:w00t:
Posting Best Practices[/url]
Numbers / Tally Tables[/url]
September 15, 2008 at 12:44 pm
duh! This was a permissions problem and I have it working now. Thanks for pointing me in the right direction. Have a great week! 😀
Viewing 7 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply