Datatable insertion in SQL using c# -


How can we insert the values ​​of data in SQL using C #? And the second question is how can we copy the SQL table into Datawarb?

update : One thing is that the answer was not in the past There is a link to information for SQL and Database News, so I will also put some relevant links here so that you (or anyone else) can brush on my SQL and other database design skills.


  • UPDATE 2 : Here's an example to fill out a figure:

      // namespace system. References using data; System.Data.SqlClient/// & lt; Summary & gt; /// Returns the data base based on the command passed /// & lt; / Summary & gt; /// & lt; Param name = "cmd" & gt; /// SQL Command Object that we want to execute /// & lt; / Param & gt; /// & lt; Returns & gt; /// is populated with a datatable SQL command object specified in / var /// & lt; / Returns> /// & lt; Comment & gt; & Lt; / Comment & gt; Public stable datatable GetDataTable (SqlCommand CMD) {try {// Make a new data adaptter based on a specified data. SqlDataAdapter da = New SqlDataAdapter (); Set the selection of // Adapter Da. SelectionCommand = cmd; // Create a new datatable datatable dtGet = new datatile (); // fill the datatable da. Fill (dtGet); // DataTable return dtGet return; } Hold (SqlException East) {MessageBox.Show (ex.Message); } Hold (Exception pre) {Message Box. Show (ex.Message); }}  

    It has been written a long time ago with another answer, but it comes in detail about your exact issues:

    Original Answer :

    It is necessary that you need a basic introduction by adding and adding a database from C #. The above poster asked LINQ to look at SQL, but you have ADO You can also consider Net's basic infrastructure, which you will find to understand the basics of how it works.

    In addition, you use this site for many database tutorials for C #.

    Edit : More information than, and

    Edit 2 : If you are interested in things like Linux from Linux As others have said above, there are some tutorials from here, and

    edit 3 : Others will also suggest ADO. Net Entity Framework I would like to suggest that it is not necessary for those beginners, who still need to understand the basics of working with the database.

    A simple example here is some information (this is pulled directly from the above C # station link)

    list 1 Use SqlConnection

      using the system; Using System.Data; Using System.Data.SqlClient; /// & lt; Summary & gt; /// Provides to work with the SqlConnection object; /// & lt; / Summary & gt; Class SqlConnectionDemo {static zero main () {// 1. Connection SqlConnection conn = New SqlConnection ("Data Source = (Local); Initial List = NorthWind; Integrated Security = SSPI"); SqlDataReader rdr = null; Try {// 2. Open connection Conn.Open (); // 3. Command object SqlCommand CMD = New connection to SqlCommand ("Select from customers", Conn); // // 4. Use connection // // query result rdr = cmd.ExecuteReader (); // Printing every record's customer ID (rdr.Read ()) {Console.WriteLine (rdr [0]); }} Finally close the {// reader if (rdr! = Null) {rdr.Close (); } // 5. Close the connection if (conn! = Null) {conn.Close (); }}}}  

    Comments

    Popular posts from this blog

    python - Overriding the save method in Django ModelForm -

    html - CSS autoheight, but fit content to height of div -

    qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -