TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Dean Guenther
NA
4
0
problem inserting to a table
Jun 21 2006 2:00 PM
Hi folks, I'm new to SQL and I'm having trouble inserting into a table. I have a database called "nidmaint" and in it I have a table called "KeyCache". This is SQL 8 on a remote system called lancelot. When I run this code, I successfully connect to the database when I do the mConnection.Open statement and follow through with the VS debugger. But when I do the myDataAdapter.Update statement, it throws an exception "Update unable to find TableMapping['KeyCache'] or DataTable 'KeyCache'." SqlConnection myConnection; string SConstring; string sSQL; SConstring = "user id=nidmaint;password=********;database=nidmaint;server=lancelot"; sSQL = "insert into KeyCache (Key_ID) values ('1234')"; myConnection = new SqlConnection(SConstring); DataSet myDataset = new DataSet(); myConnection.Open(); SqlDataAdapter myDataAdapter = new SqlDataAdapter(sSQL, myConnection); myDataAdapter.Update(myDataset,"KeyCache"); myDataset.AcceptChanges(); myConnection.Close(); I did run the insert statement in SQL analyzer and it did successfully add a row into the KeyCache table. In doing a google on this error, I've seen several who've had this error. But comments seemed to focus on the table didn't exist. But the table is there. I did see somebody's comment about printing the name of the table using myDataset.Tables(0).TableName but intellisense doesn't show TableName as an option. Maybe its the version I'm using which is Visual Studio 2005. I do see in the debugger that I have a myDataset.Tables.Count value which is "0". At first I thought maybe that showed that I had no tables, but it appears to me that the first table located at myDataset.Tables[x] actually starts at zero not at one, so maybe the Count is correct? Anyway, what does it look like I'm doing wrong here? thanks - Dean
Reply
Answers (
1
)
Interactive Report
Date Format