angel1507 Posted July 29, 2010 Posted July 29, 2010 (edited) hi i m a cmpleletely newbie in this asp.net field.I have written the following module to update my database by clicking a button. But its giving me an error msg at the line MyAdapter.Fill(MyTable); saying "invalid table name". protected void cmdupdate_Click(object sender, EventArgs e) { if (Page.IsPostBack==true) { DataTable MyTable = new DataTable(); System.Data.OracleClient.OracleConnection conn; OracleCommand cmd; string cmdString1 = "update table hr_rmc_file_mast set file_division=FILE_DIVISION.Text,file_no=FILE_NO.Text,project_code=PROJECT_CODE.Text,no_of_noting=NO_OF_NOTING.Text,no_of_corresponence=NO_OF_CORRESP.Text,subject=SUBJECT.Text,record_class=RECORD_CLASS.Text,prv_ref=PRV_REF.Text,later_ref=LATER_REF.Text,retention_period=RETENTION_PERIOD.Text,destruction_year=DESTRUCTION_YEAR.Text,proceeding_no=PROCEEDING_NO.Text ,user_id=USER_ID.Text ,trans_date=TRANS_DATE.Text,comp_no=COMP_NO.Text,rec_no=REC_NO.Text,sent_by=SENT_BY.Text,sent_dt=SENT_DT.Text where file_no=FILE_NO.Text"; //conn = new OracleConnection("User Id=system;Password=project;Data Source=SqlDataSource1"); conn = new OracleConnection(ConfigurationManager.ConnectionStrings["ConnectionString12"].ConnectionString); cmd = new OracleCommand(cmdString1, conn); OracleDataAdapter MyAdapter = new OracleDataAdapter(); conn.Open(); MyAdapter.SelectCommand = cmd; MyAdapter.Fill(MyTable); ListView1.DataSource=MyTable.DefaultView; ListView1.DataBind(); MyAdapter.Dispose(); cmd.Dispose(); conn.Dispose(); // conn.Close(); } } I'll b vry grateful if ny1 cud hlp me wid dis.!! Edited July 29, 2010 by PlausiblyDamp Quote
Administrators PlausiblyDamp Posted July 29, 2010 Administrators Posted July 29, 2010 The command you are using doesn't appear to return any data, the .Fill method is expecting a result set it can use to populate the dataset - is that really the correct command? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
angel1507 Posted July 29, 2010 Author Posted July 29, 2010 (edited) thnx 4 replying... u mean 2 say ..i shud give a whole valid row as an input. I hv tried it but its not wrking nyway!!:( A similar error comes up with my insert func with cmd.ExecuteNonQuery() Code: protected void Button1_Click(object sender, EventArgs e) { System.Data.OracleClient.OracleConnection conn; OracleCommand cmd; //string cmdString = "Select CompanyName from Customers"; string cmdString = "insert into hr_rmc_file_mast(file_division,file_no,project_code,no_of_noting,no_of_corresponence,subject,record_class,prv_ref,later_ref,retention_period,destruction_year,proceeding_no ,user_id ,trans_date ,comp_no ,rec_no ,sent_by ,sent_dt ) values('" + FILE_DIVISION.Text + "', '" + FILE_NO.Text + "', '" + PROJECT_CODE.Text + "', '" + NO_OF_NOTING.Text + "', '" + NOOFCORRESP.Text + "', '" + SUBJECT.Text + "', '" + RECORD_CLASS.Text + "', '" + PRV_REF.Text + "', '" + LATER_REF.Text + "', '" + RETENTION_PERIOD.Text + "', '" + DESTRUCTION_YEAR.Text + "', '" + PROCEEDING_NO.Text + "', '" + USER_ID.Text + "', '" + TRANS_DATE.Text + "', '" + COMP_NO.Text + "', '" + REC_NO.Text + "', '" + SENT_BY.Text + "', '" + SENT_DT.Text + "');"; conn = new OracleConnection(ConfigurationManager.ConnectionStrings["ConnectionString12"].ConnectionString); cmd = new OracleCommand(cmdString, conn); conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); } [/CS] Plz hlp!! Edited July 31, 2010 by PlausiblyDamp Quote
Administrators PlausiblyDamp Posted July 31, 2010 Administrators Posted July 31, 2010 Does that table actually exist in the place you are looking? Are you sure you are in the correct database and that you are accessing it from the correct schema. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.