Click here to Skip to main content
15,914,417 members
Home / Discussions / Database
   

Database

 
AnswerRe: how to join two tables Pin
Krish - KP4-Jul-07 21:31
Krish - KP4-Jul-07 21:31 
Questionhow to join two tables Pin
harithadotnet4-Jul-07 18:29
harithadotnet4-Jul-07 18:29 
AnswerRe: how to join two tables [modified] Pin
Krish - KP4-Jul-07 18:49
Krish - KP4-Jul-07 18:49 
AnswerRe: how to join two tables Pin
Michael Sync4-Jul-07 18:49
Michael Sync4-Jul-07 18:49 
QuestionHow can I call a DB2 system procedure GET_DBSIZE_INFO by .net? Pin
Jameson_cn4-Jul-07 17:54
Jameson_cn4-Jul-07 17:54 
Questionproblem with GetChanges [modified] Pin
goldoche4-Jul-07 9:14
goldoche4-Jul-07 9:14 
AnswerRe: problem with GetChanges Pin
goldoche4-Jul-07 10:38
goldoche4-Jul-07 10:38 
QuestionUsing a DataSet to insert data in a table througth a sproc Pin
Le centriste4-Jul-07 4:35
Le centriste4-Jul-07 4:35 
I am trying to insert data in a table, using a sproc. I want to do this because the current code is doing this through a foreach loop. I want to get rid of it. Here is the code I made (this is test code, not the real one):

using System;
using System.Data;
using System.Data.SqlClient;

namespace DataSetTest
{
    class Program
    {
        static void Main(string[] args)
        {
            DataSet ds = GetDataSet();
            SqlConnection conn = new SqlConnection("Server=DEVRDABTS01\\MSDEVPARA;database=sandbox; Integrated Security=SSPI");
            conn.Open();

            SqlCommand comm = new SqlCommand("usp_DatasetTest_Insert", conn);
            comm.CommandType = CommandType.StoredProcedure;

            SqlDataAdapter da = new SqlDataAdapter();
            da.InsertCommand = comm;

            da.Update(ds); //<---- Error here
        }

        public static DataSet GetDataSet()
        {
            DataSet returnDS = new DataSet();
            DataTable dt = returnDS.Tables.Add("DatasetTest");

            dt.Columns.Add("dateValue", typeof(DateTime));
            dt.Columns.Add("clientId", typeof(string));
            dt.Columns.Add("stringValue", typeof(string));
            dt.Columns.Add("dontInsertIfNull", typeof(string));

            DataRow dr;

            for (int i = 0; i < 10; ++i)
            {
                dr = dt.NewRow();

                dr[0] = DateTime.Now;
                dr[1] = i.ToString();
                dr[2] = "some string";
                dr[3] = (i % 2) == 0 ? "" : "this is not null";

                //dr.SetAdded();

                dt.Rows.Add(dr);
            }

            return returnDS;
        }
    }
}


I get the following exception at the line marked above:

System.InvalidOperationException was unhandled
Message="Update unable to find TableMapping['Table'] or DataTable 'Table'."
Source="System.Data"
StackTrace:
at System.Data.Common.DbDataAdapter.Update(DataSet dataSet, String srcTable)
at System.Data.Common.DbDataAdapter.Update(DataSet dataSet)
at DataSetTest.Program.Main(String[] args) in c:\projets\Visual Studio 2005\Projects\DataSetTest\DataSetTest\Program.cs:line 21
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

Is it possible to make this work?

-----

If atheism is a religion, then not collecting stamps is a hobby. -- Unknown

AnswerRe: Using a DataSet to insert data in a table througth a sproc Pin
goldoche4-Jul-07 9:46
goldoche4-Jul-07 9:46 
QuestionSQL query... need help Pin
Diana18114-Jul-07 4:02
Diana18114-Jul-07 4:02 
AnswerRe: SQL query... need help Pin
andyharman4-Jul-07 9:00
professionalandyharman4-Jul-07 9:00 
GeneralRe: SQL query... need help Pin
Diana18114-Jul-07 17:28
Diana18114-Jul-07 17:28 
GeneralRe: SQL query... need help Pin
Pete O'Hanlon4-Jul-07 22:29
mvePete O'Hanlon4-Jul-07 22:29 
AnswerRe: SQL query... need help Pin
andyharman4-Jul-07 22:46
professionalandyharman4-Jul-07 22:46 
GeneralRe: SQL query... need help Pin
Diana18116-Jul-07 0:39
Diana18116-Jul-07 0:39 
GeneralFunny with SELECT ... INTO Pin
Brady Kelly3-Jul-07 23:58
Brady Kelly3-Jul-07 23:58 
GeneralRe: Funny with SELECT ... INTO Pin
andyharman4-Jul-07 1:22
professionalandyharman4-Jul-07 1:22 
GeneralRe: Funny with SELECT ... INTO Pin
Mike Dimmick4-Jul-07 3:31
Mike Dimmick4-Jul-07 3:31 
QuestionRunning a SQL Script file using C# Pin
wasife3-Jul-07 19:25
wasife3-Jul-07 19:25 
AnswerRe: Running a SQL Script file using C# Pin
Colin Angus Mackay3-Jul-07 22:44
Colin Angus Mackay3-Jul-07 22:44 
GeneralRe: Running a SQL Script file using C# Pin
N a v a n e e t h4-Jul-07 3:33
N a v a n e e t h4-Jul-07 3:33 
GeneralRe: Running a SQL Script file using C# Pin
Colin Angus Mackay4-Jul-07 7:00
Colin Angus Mackay4-Jul-07 7:00 
GeneralRe: Running a SQL Script file using C# Pin
N a v a n e e t h4-Jul-07 18:20
N a v a n e e t h4-Jul-07 18:20 
GeneralRe: Running a SQL Script file using C# Pin
Colin Angus Mackay4-Jul-07 21:26
Colin Angus Mackay4-Jul-07 21:26 
QuestionColumn info in SQL Server 2005 Pin
I.explore.code3-Jul-07 18:39
I.explore.code3-Jul-07 18:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.