 




<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: VB.NET &#8211; Can&#8217;t insert data into database.</title>
	<atom:link href="http://itknowledgeexchange.techtarget.com/itanswers/cant-insert-data-into-database/feed/" rel="self" type="application/rss+xml" />
	<link>http://itknowledgeexchange.techtarget.com/itanswers/cant-insert-data-into-database/</link>
	<description></description>
	<lastBuildDate>Sun, 26 May 2013 01:40:27 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>By: shaz</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/cant-insert-data-into-database/#comment-64374</link>
		<dc:creator>shaz</dc:creator>
		<pubDate>Thu, 11 Jun 2009 10:41:57 +0000</pubDate>
		<guid isPermaLink="false">#comment-64374</guid>
		<description><![CDATA[In form in text box after entering valules,hitting with enter from keyboard is not working and i want after storing values in the database  the form should beome  clear for entering new values plz tell all above  solutions

Thanking u

shaz]]></description>
		<content:encoded><![CDATA[<p>In form in text box after entering valules,hitting with enter from keyboard is not working and i want after storing values in the database  the form should beome  clear for entering new values plz tell all above  solutions</p>
<p>Thanking u</p>
<p>shaz</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shaz</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/cant-insert-data-into-database/#comment-64373</link>
		<dc:creator>shaz</dc:creator>
		<pubDate>Thu, 11 Jun 2009 10:21:44 +0000</pubDate>
		<guid isPermaLink="false">#comment-64373</guid>
		<description><![CDATA[Thank for helping it worked out,but the problem which values i have given in database r inserting in database.I dont want like that,I want in such a way any person will fill admission form the values should enter into database directly and store ,how to do it,i will not write values in coding.so give the solution plz
shaz]]></description>
		<content:encoded><![CDATA[<p>Thank for helping it worked out,but the problem which values i have given in database r inserting in database.I dont want like that,I want in such a way any person will fill admission form the values should enter into database directly and store ,how to do it,i will not write values in coding.so give the solution plz<br />
shaz</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: carlosdl</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/cant-insert-data-into-database/#comment-64311</link>
		<dc:creator>carlosdl</dc:creator>
		<pubDate>Mon, 08 Jun 2009 20:32:07 +0000</pubDate>
		<guid isPermaLink="false">#comment-64311</guid>
		<description><![CDATA[That is an error message from Sql Server.  Your insert sql command seems to be incorrect.

It should be something similar to this:

&lt;pre&gt;&quot;
Dim insertSql As String = “Insert into SAdmission(RegistrationNo,Name,DateofBirth,Class,Nationality,MotherTongue,Religion,BloodGroup,SecondLanguage,Address1,Address2,PhoneNo,DateofJoining,FathersName,Occupation,MothersName,Occupation1) values (@RegistrationNo,@Name,@DateofBirth,@Class,@Nationality,@MotherTongue,@Religion,@BloodGroup,@SecondLanguage,@Address1,@Address2,@PhoneNo,@DateofJoining,@FathersName,@Occupation,@MothersName,@Occupation1)”
&quot;&lt;/pre&gt;]]></description>
		<content:encoded><![CDATA[<p>That is an error message from Sql Server.  Your insert sql command seems to be incorrect.</p>
<p>It should be something similar to this:</p>
<pre>"
Dim insertSql As String = “Insert into SAdmission(RegistrationNo,Name,DateofBirth,Class,Nationality,MotherTongue,Religion,BloodGroup,SecondLanguage,Address1,Address2,PhoneNo,DateofJoining,FathersName,Occupation,MothersName,Occupation1) values (@RegistrationNo,@Name,@DateofBirth,@Class,@Nationality,@MotherTongue,@Religion,@BloodGroup,@SecondLanguage,@Address1,@Address2,@PhoneNo,@DateofJoining,@FathersName,@Occupation,@MothersName,@Occupation1)”
"</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: shaz</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/cant-insert-data-into-database/#comment-64305</link>
		<dc:creator>shaz</dc:creator>
		<pubDate>Mon, 08 Jun 2009 16:15:47 +0000</pubDate>
		<guid isPermaLink="false">#comment-64305</guid>
		<description><![CDATA[Thanks for helping me but iam geeting errors plz have alook at my code and guide me.the following errors iam gettting.

Before altering the dataset
=========
After altering the dataset
1          &#124; Nameera    &#124; 16/12/2006
Error: System.Data.SqlClient.SqlException: Incorrect syntax near &#039;(&#039;.
   at System.Data.Common.DbDataAdapter.UpdatedRowStatusErrors(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
   at System.Data.Common.DbDataAdapter.UpdatedRowStatus(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
   at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping)
   at System.Data.Common.DbDataAdapter.UpdateFromDataTable(DataTable dataTable, DataTableMapping tableMapping)
   at System.Data.Common.DbDataAdapter.Update(DataSet dataSet, String srcTable)
   at School.SAdmission.Button2_Click(Object sender, EventArgs e) in D:Visual Studio 2005SchoolSchoolSAdmission.vb:line 123
Connection Closed


My code is as below

Imports System
Imports System.Collections
Imports System.Data
Imports System.IO
Imports System.Xml.Serialization
Imports System.Windows.Forms
Imports System.Data.SqlClient



Public Class SAdmission

    Shared Sub Main()
        
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.Hide()
        Home.Show()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim thisConnection As New SqlConnection(&quot;Data Source=NASSQLEXPRESS;Database=data2;Integrated Security=True; Connect Timeout=30;&quot;)


        Dim sql As String = &quot;SELECT * FROM SAdmission &quot;



        Dim insertSql As String = &quot;Insert into SAdmission(RegistrationNo,Name,DateofBirth,Class,Nationality,MotherTongue,Religion,BloodGroup,SecondLanguage,Address1,Address2,PhoneNo,DateofJoining,FathersName,Occupation,MothersName,Occupation1)values(&quot; &#039;RegistrationNo’,&#039;Name’,&#039;DateofBirth’,&#039;Class’,&#039;Nationality’,&#039;MotherTongue’,&#039;Religion’,&#039;BloodGroup’,&#039;SecondLanguage’,&#039;Address1′,’Address2′,’PhoneNo’,&#039;DateofJoining’,&#039;FathersName’,&#039;Occupation’,&#039;MothersName’,&#039;Occupation1′&quot;)&quot;
        Try

            Dim da As New SqlDataAdapter
            da.SelectCommand = New SqlCommand(sql, thisConnection)

            &#039; Create and fill Dataset
            Dim ds As New DataSet
            da.Fill(ds, &quot;SAdmission&quot;)
            &#039; Get the Data Table
            Dim dt As DataTable = ds.Tables(&quot;SAdmission&quot;)
            Console.WriteLine(&quot;Before altering the dataset&quot;)
            For Each row As DataRow In dt.Rows
                Console.WriteLine(&quot;{0} &#124; {1} &#124; {2}&quot;, _
                   row(&quot;RegistrationNo&quot;).ToString().PadRight(10), _
                   row(&quot;Name&quot;).ToString().PadRight(10), _
                   row(&quot;DateofBirth&quot;).ToString().PadRight(10), _
                row(&quot;Class&quot;).ToString().PadRight(10), _
                row(&quot;Nationality&quot;).ToString().PadRight(10), _
                row(&quot;MotherTongue&quot;).ToString().PadRight(10), _
                row(&quot;BloodGroup&quot;).ToString().PadRight(10), _
                row(&quot;SecondLanguage&quot;).ToString().PadRight(10), _
                row(&quot;Address1&quot;).ToString().PadRight(10), _
                row(&quot;Address2&quot;).ToString().PadRight(10), _
                row(&quot;PhoneNo&quot;).ToString().PadRight(10), _
                row(&quot;DateofJoining&quot;).ToString().PadRight(10), _
                row(&quot;FathersName&quot;).ToString().PadRight(10), _
                row(&quot;Occupation&quot;).ToString().PadRight(10), _
                row(&quot;MothersName&quot;).ToString().PadRight(10), _
                row(&quot;Occupation1&quot;).ToString().PadRight(10))
            Next
            Dim newRow As DataRow = dt.NewRow()
            newRow(&quot;RegistrationNo&quot;) = &quot;1&quot;
            newRow(&quot;Name&quot;) = &quot;Nameera&quot;
            newRow(&quot;DateofBirth&quot;) = &quot;16/12/2006&quot;
            dt.Rows.Add(newRow)
            Console.WriteLine(&quot;=========&quot;)
            Console.WriteLine(&quot;After altering the dataset&quot;)
            For Each row As DataRow In dt.Rows
                Console.WriteLine(&quot;{0} &#124; {1} &#124; {2}&quot;, _
                   row(&quot;RegistrationNo&quot;).ToString().PadRight(10), _
               row(&quot;Name&quot;).ToString().PadRight(10), _
               row(&quot;DateofBirth&quot;).ToString().PadRight(10), _
            row(&quot;Class&quot;).ToString().PadRight(10), _
            row(&quot;Nationality&quot;).ToString().PadRight(10), _
            row(&quot;MotherTongue&quot;).ToString().PadRight(10), _
            row(&quot;BloodGroup&quot;).ToString().PadRight(10), _
            row(&quot;SecondLanguage&quot;).ToString().PadRight(10), _
            row(&quot;Address1&quot;).ToString().PadRight(10), _
            row(&quot;Address2&quot;).ToString().PadRight(10), _
            row(&quot;PhoneNo&quot;).ToString().PadRight(10), _
            row(&quot;DateofJoining&quot;).ToString().PadRight(10), _
            row(&quot;FathersName&quot;).ToString().PadRight(10), _
            row(&quot;Occupation&quot;).ToString().PadRight(10), _
            row(&quot;MothersName&quot;).ToString().PadRight(10), _
            row(&quot;Occupation1&quot;).ToString().PadRight(10))
            Next
            
                Dim insertCmd As New SqlCommand(insertSql, thisConnection)
                insertCmd.Parameters.Add(&quot;@RegistrationNo&quot;, _
                            SqlDbType.NVarChar, 10, &quot;RegistrationNo&quot;)
                insertCmd.Parameters.Add(&quot;@Name&quot;, _
                   SqlDbType.NVarChar, 20, &quot;Name&quot;)
            insertCmd.Parameters.Add(&quot;@DateofBirth&quot;, _
               SqlDbType.NVarChar, 15, &quot;DateofBirth&quot;)
                insertCmd.Parameters.Add(&quot;@Class&quot;, _
                   SqlDbType.NVarChar, 20, &quot;Class&quot;)
                insertCmd.Parameters.Add(&quot;@Nationality&quot;, _
                   SqlDbType.NVarChar, 20, &quot;Nationality&quot;)
                insertCmd.Parameters.Add(&quot;@MotherTongue&quot;, _
                   SqlDbType.NVarChar, 20, &quot;MotherTongue&quot;)
                insertCmd.Parameters.Add(&quot;@Religion&quot;, _
                   SqlDbType.NVarChar, 20, &quot;Religion&quot;)
                insertCmd.Parameters.Add(&quot;@BloodGroup&quot;, _
                   SqlDbType.NVarChar, 20, &quot;BloodGroup&quot;)
                insertCmd.Parameters.Add(&quot;@SecondLanguage&quot;, _
                   SqlDbType.NVarChar, 20, &quot;secondlanguage&quot;)
                insertCmd.Parameters.Add(&quot;@Address1&quot;, _
                   SqlDbType.NVarChar, 20, &quot;Address1&quot;)
                insertCmd.Parameters.Add(&quot;@Address2&quot;, _
                   SqlDbType.NVarChar, 20, &quot;Address2&quot;)
                insertCmd.Parameters.Add(&quot;@PhoneNo&quot;, _
                   SqlDbType.NVarChar, 20, &quot;PhoneNo&quot;)
                insertCmd.Parameters.Add(&quot;@DateofJoining&quot;, _
                   SqlDbType.NVarChar, 20, &quot;DateofJoining&quot;)
                insertCmd.Parameters.Add(&quot;@FathersName&quot;, _
                   SqlDbType.NVarChar, 20, &quot;FathersName&quot;)
                insertCmd.Parameters.Add(&quot;@Occupation&quot;, _
                   SqlDbType.NVarChar, 20, &quot;Occupation&quot;)
                insertCmd.Parameters.Add(&quot;@MothersName&quot;, _
                   SqlDbType.NVarChar, 20, &quot;MothersName&quot;)
                insertCmd.Parameters.Add(&quot;@Occupation1&quot;, _
                   SqlDbType.NVarChar, 20, &quot;Occupation1&quot;)
                da.InsertCommand = insertCmd
                da.Update(ds, &quot;SAdmission&quot;)
        Catch ex As SqlException
            Console.WriteLine(&quot;Error: &quot; &amp; ex.ToString())
        Finally
            thisConnection.Close()
            Console.WriteLine(&quot;Connection Closed&quot;)
        End Try
    End Sub


   
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Me.Close()

    End Sub
End Class]]></description>
		<content:encoded><![CDATA[<p>Thanks for helping me but iam geeting errors plz have alook at my code and guide me.the following errors iam gettting.</p>
<p>Before altering the dataset<br />
=========<br />
After altering the dataset<br />
1          | Nameera    | 16/12/2006<br />
Error: System.Data.SqlClient.SqlException: Incorrect syntax near &#8216;(&#8216;.<br />
   at System.Data.Common.DbDataAdapter.UpdatedRowStatusErrors(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)<br />
   at System.Data.Common.DbDataAdapter.UpdatedRowStatus(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)<br />
   at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping)<br />
   at System.Data.Common.DbDataAdapter.UpdateFromDataTable(DataTable dataTable, DataTableMapping tableMapping)<br />
   at System.Data.Common.DbDataAdapter.Update(DataSet dataSet, String srcTable)<br />
   at School.SAdmission.Button2_Click(Object sender, EventArgs e) in D:Visual Studio 2005SchoolSchoolSAdmission.vb:line 123<br />
Connection Closed</p>
<p>My code is as below</p>
<p>Imports System<br />
Imports System.Collections<br />
Imports System.Data<br />
Imports System.IO<br />
Imports System.Xml.Serialization<br />
Imports System.Windows.Forms<br />
Imports System.Data.SqlClient</p>
<p>Public Class SAdmission</p>
<p>    Shared Sub Main()</p>
<p>    End Sub<br />
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click<br />
        Me.Hide()<br />
        Home.Show()<br />
    End Sub</p>
<p>    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click<br />
        Dim thisConnection As New SqlConnection(&#8220;Data Source=NASSQLEXPRESS;Database=data2;Integrated Security=True; Connect Timeout=30;&#8221;)</p>
<p>        Dim sql As String = &#8220;SELECT * FROM SAdmission &#8221;</p>
<p>        Dim insertSql As String = &#8220;Insert into SAdmission(RegistrationNo,Name,DateofBirth,Class,Nationality,MotherTongue,Religion,BloodGroup,SecondLanguage,Address1,Address2,PhoneNo,DateofJoining,FathersName,Occupation,MothersName,Occupation1)values(&#8221; &#8216;RegistrationNo’,&#8217;Name’,&#8217;DateofBirth’,&#8217;Class’,&#8217;Nationality’,&#8217;MotherTongue’,&#8217;Religion’,&#8217;BloodGroup’,&#8217;SecondLanguage’,&#8217;Address1′,’Address2′,’PhoneNo’,&#8217;DateofJoining’,&#8217;FathersName’,&#8217;Occupation’,&#8217;MothersName’,&#8217;Occupation1′&#8221;)&#8221;<br />
        Try</p>
<p>            Dim da As New SqlDataAdapter<br />
            da.SelectCommand = New SqlCommand(sql, thisConnection)</p>
<p>            &#8216; Create and fill Dataset<br />
            Dim ds As New DataSet<br />
            da.Fill(ds, &#8220;SAdmission&#8221;)<br />
            &#8216; Get the Data Table<br />
            Dim dt As DataTable = ds.Tables(&#8220;SAdmission&#8221;)<br />
            Console.WriteLine(&#8220;Before altering the dataset&#8221;)<br />
            For Each row As DataRow In dt.Rows<br />
                Console.WriteLine(&#8220;{0} | {1} | {2}&#8221;, _<br />
                   row(&#8220;RegistrationNo&#8221;).ToString().PadRight(10), _<br />
                   row(&#8220;Name&#8221;).ToString().PadRight(10), _<br />
                   row(&#8220;DateofBirth&#8221;).ToString().PadRight(10), _<br />
                row(&#8220;Class&#8221;).ToString().PadRight(10), _<br />
                row(&#8220;Nationality&#8221;).ToString().PadRight(10), _<br />
                row(&#8220;MotherTongue&#8221;).ToString().PadRight(10), _<br />
                row(&#8220;BloodGroup&#8221;).ToString().PadRight(10), _<br />
                row(&#8220;SecondLanguage&#8221;).ToString().PadRight(10), _<br />
                row(&#8220;Address1&#8243;).ToString().PadRight(10), _<br />
                row(&#8220;Address2&#8243;).ToString().PadRight(10), _<br />
                row(&#8220;PhoneNo&#8221;).ToString().PadRight(10), _<br />
                row(&#8220;DateofJoining&#8221;).ToString().PadRight(10), _<br />
                row(&#8220;FathersName&#8221;).ToString().PadRight(10), _<br />
                row(&#8220;Occupation&#8221;).ToString().PadRight(10), _<br />
                row(&#8220;MothersName&#8221;).ToString().PadRight(10), _<br />
                row(&#8220;Occupation1&#8243;).ToString().PadRight(10))<br />
            Next<br />
            Dim newRow As DataRow = dt.NewRow()<br />
            newRow(&#8220;RegistrationNo&#8221;) = &#8220;1&#8243;<br />
            newRow(&#8220;Name&#8221;) = &#8220;Nameera&#8221;<br />
            newRow(&#8220;DateofBirth&#8221;) = &#8220;16/12/2006&#8243;<br />
            dt.Rows.Add(newRow)<br />
            Console.WriteLine(&#8220;=========&#8221;)<br />
            Console.WriteLine(&#8220;After altering the dataset&#8221;)<br />
            For Each row As DataRow In dt.Rows<br />
                Console.WriteLine(&#8220;{0} | {1} | {2}&#8221;, _<br />
                   row(&#8220;RegistrationNo&#8221;).ToString().PadRight(10), _<br />
               row(&#8220;Name&#8221;).ToString().PadRight(10), _<br />
               row(&#8220;DateofBirth&#8221;).ToString().PadRight(10), _<br />
            row(&#8220;Class&#8221;).ToString().PadRight(10), _<br />
            row(&#8220;Nationality&#8221;).ToString().PadRight(10), _<br />
            row(&#8220;MotherTongue&#8221;).ToString().PadRight(10), _<br />
            row(&#8220;BloodGroup&#8221;).ToString().PadRight(10), _<br />
            row(&#8220;SecondLanguage&#8221;).ToString().PadRight(10), _<br />
            row(&#8220;Address1&#8243;).ToString().PadRight(10), _<br />
            row(&#8220;Address2&#8243;).ToString().PadRight(10), _<br />
            row(&#8220;PhoneNo&#8221;).ToString().PadRight(10), _<br />
            row(&#8220;DateofJoining&#8221;).ToString().PadRight(10), _<br />
            row(&#8220;FathersName&#8221;).ToString().PadRight(10), _<br />
            row(&#8220;Occupation&#8221;).ToString().PadRight(10), _<br />
            row(&#8220;MothersName&#8221;).ToString().PadRight(10), _<br />
            row(&#8220;Occupation1&#8243;).ToString().PadRight(10))<br />
            Next</p>
<p>                Dim insertCmd As New SqlCommand(insertSql, thisConnection)<br />
                insertCmd.Parameters.Add(&#8220;@RegistrationNo&#8221;, _<br />
                            SqlDbType.NVarChar, 10, &#8220;RegistrationNo&#8221;)<br />
                insertCmd.Parameters.Add(&#8220;@Name&#8221;, _<br />
                   SqlDbType.NVarChar, 20, &#8220;Name&#8221;)<br />
            insertCmd.Parameters.Add(&#8220;@DateofBirth&#8221;, _<br />
               SqlDbType.NVarChar, 15, &#8220;DateofBirth&#8221;)<br />
                insertCmd.Parameters.Add(&#8220;@Class&#8221;, _<br />
                   SqlDbType.NVarChar, 20, &#8220;Class&#8221;)<br />
                insertCmd.Parameters.Add(&#8220;@Nationality&#8221;, _<br />
                   SqlDbType.NVarChar, 20, &#8220;Nationality&#8221;)<br />
                insertCmd.Parameters.Add(&#8220;@MotherTongue&#8221;, _<br />
                   SqlDbType.NVarChar, 20, &#8220;MotherTongue&#8221;)<br />
                insertCmd.Parameters.Add(&#8220;@Religion&#8221;, _<br />
                   SqlDbType.NVarChar, 20, &#8220;Religion&#8221;)<br />
                insertCmd.Parameters.Add(&#8220;@BloodGroup&#8221;, _<br />
                   SqlDbType.NVarChar, 20, &#8220;BloodGroup&#8221;)<br />
                insertCmd.Parameters.Add(&#8220;@SecondLanguage&#8221;, _<br />
                   SqlDbType.NVarChar, 20, &#8220;secondlanguage&#8221;)<br />
                insertCmd.Parameters.Add(&#8220;@Address1&#8243;, _<br />
                   SqlDbType.NVarChar, 20, &#8220;Address1&#8243;)<br />
                insertCmd.Parameters.Add(&#8220;@Address2&#8243;, _<br />
                   SqlDbType.NVarChar, 20, &#8220;Address2&#8243;)<br />
                insertCmd.Parameters.Add(&#8220;@PhoneNo&#8221;, _<br />
                   SqlDbType.NVarChar, 20, &#8220;PhoneNo&#8221;)<br />
                insertCmd.Parameters.Add(&#8220;@DateofJoining&#8221;, _<br />
                   SqlDbType.NVarChar, 20, &#8220;DateofJoining&#8221;)<br />
                insertCmd.Parameters.Add(&#8220;@FathersName&#8221;, _<br />
                   SqlDbType.NVarChar, 20, &#8220;FathersName&#8221;)<br />
                insertCmd.Parameters.Add(&#8220;@Occupation&#8221;, _<br />
                   SqlDbType.NVarChar, 20, &#8220;Occupation&#8221;)<br />
                insertCmd.Parameters.Add(&#8220;@MothersName&#8221;, _<br />
                   SqlDbType.NVarChar, 20, &#8220;MothersName&#8221;)<br />
                insertCmd.Parameters.Add(&#8220;@Occupation1&#8243;, _<br />
                   SqlDbType.NVarChar, 20, &#8220;Occupation1&#8243;)<br />
                da.InsertCommand = insertCmd<br />
                da.Update(ds, &#8220;SAdmission&#8221;)<br />
        Catch ex As SqlException<br />
            Console.WriteLine(&#8220;Error: &#8221; &amp; ex.ToString())<br />
        Finally<br />
            thisConnection.Close()<br />
            Console.WriteLine(&#8220;Connection Closed&#8221;)<br />
        End Try<br />
    End Sub</p>
<p>    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click<br />
        Me.Close()</p>
<p>    End Sub<br />
End Class</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: carlosdl</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/cant-insert-data-into-database/#comment-64270</link>
		<dc:creator>carlosdl</dc:creator>
		<pubDate>Fri, 05 Jun 2009 17:12:28 +0000</pubDate>
		<guid isPermaLink="false">#comment-64270</guid>
		<description><![CDATA[Did you take a look at the link I suggested for an insert example ??

As stated above, the Update method of the data adapter &lt;i&gt;changes the data in the data source &lt;b&gt;to match the data in the DataSet&lt;/i&gt;&lt;/b&gt;, but you don&#039;t have any data in the data set, and I think that is the problem.

This is the description of the InsertCommand property:

&quot;A SqlCommand used during Update to insert records into the database &lt;b&gt;that correspond to new rows in the DataSet&lt;/b&gt;.&quot;

If you want to insert records into the database table through a dataset, you need to add those new records to the dataset first, and remember that the Update method will perform any necessary actions to synchronize information between the data source, and the dataset, so if your dataset has only 1 row, I guess that is what you will have in the underlying table after the update.

&lt;i&gt;Please&lt;/i&gt;, have a look at the following example on using datasets and data adapters:

&lt;a href=&quot;http://www.java2s.com/Code/VB/Database-ADO.net/Insertcommandwithparameters.htm&quot;&gt;Insert command with parameters&lt;/a&gt;]]></description>
		<content:encoded><![CDATA[<p>Did you take a look at the link I suggested for an insert example ??</p>
<p>As stated above, the Update method of the data adapter <i>changes the data in the data source <b>to match the data in the DataSet</b></i>, but you don&#8217;t have any data in the data set, and I think that is the problem.</p>
<p>This is the description of the InsertCommand property:</p>
<p>&#8220;A SqlCommand used during Update to insert records into the database <b>that correspond to new rows in the DataSet</b>.&#8221;</p>
<p>If you want to insert records into the database table through a dataset, you need to add those new records to the dataset first, and remember that the Update method will perform any necessary actions to synchronize information between the data source, and the dataset, so if your dataset has only 1 row, I guess that is what you will have in the underlying table after the update.</p>
<p><i>Please</i>, have a look at the following example on using datasets and data adapters:</p>
<p><a href="http://www.java2s.com/Code/VB/Database-ADO.net/Insertcommandwithparameters.htm">Insert command with parameters</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shaz</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/cant-insert-data-into-database/#comment-64269</link>
		<dc:creator>shaz</dc:creator>
		<pubDate>Fri, 05 Jun 2009 16:42:44 +0000</pubDate>
		<guid isPermaLink="false">#comment-64269</guid>
		<description><![CDATA[Thanks for helping me

Update unable to find TableMapping[&#039;SAdmission&#039;] or DataTable &#039;SAdmission&#039;. But still iam getting above error.
Imports System
Imports System.Collections
Imports System.Data
Imports System.IO
Imports System.Xml.Serialization
Imports System.Windows.Forms
Imports System.Data.SqlClient



Public Class SAdmission
    Shared WithEvents con As SqlConnection
    Shared Sub Main()

    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.Hide()
        Home.Show()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim adapter As SqlDataAdapter
        Dim cmd As SqlCommand
        Dim ds As New DataSet
        Dim test As Boolean
        Dim conn As SqlConnection

        Dim sql As String
        conn = New SqlConnection(&quot;Data Source=NASSQLEXPRESS;Database=data2;Integrated Security=True; Connect Timeout=30;&quot;)

        sql = &quot;Insert into SAdmission(RegistrationNo,Name,DateofBirth,Class,Nationality,MotherTongue,Religion,BloodGroup,SecondLanguage,Address1,Address2,PhoneNo,DateofJoining,FathersName,Occupation,MothersName,Occupation1)values(&quot; &#039;RegistrationNo’,&#039;Name’,&#039;DateofBirth’,&#039;Class’,&#039;Nationality’,&#039;MotherTongue’,&#039;Religion’,&#039;BloodGroup’,&#039;SecondLanguage’,&#039;Address1′,’Address2′,’PhoneNo’,&#039;DateofJoining’,&#039;FathersName’,&#039;Occupation’,&#039;MothersName’,&#039;Occupation1′&quot;)&quot;

        conn.Open()
        MsgBox(&quot;conection has open&quot;)
        test = conn.State    &#039;to check the connection state
        MsgBox(test)
        cmd = New SqlCommand(sql, conn)
        MessageBox.Show(cmd.CommandText.ToString())
        adapter = New SqlDataAdapter
        adapter.InsertCommand = cmd
        adapter.Update(ds, &quot;SAdmission&quot;)
        conn.Close()
        MsgBox(&quot;You have successflly updated&quot;)

    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Me.Close()

    End Sub
End Class
Plz check

Shaz]]></description>
		<content:encoded><![CDATA[<p>Thanks for helping me</p>
<p>Update unable to find TableMapping['SAdmission'] or DataTable &#8216;SAdmission&#8217;. But still iam getting above error.<br />
Imports System<br />
Imports System.Collections<br />
Imports System.Data<br />
Imports System.IO<br />
Imports System.Xml.Serialization<br />
Imports System.Windows.Forms<br />
Imports System.Data.SqlClient</p>
<p>Public Class SAdmission<br />
    Shared WithEvents con As SqlConnection<br />
    Shared Sub Main()</p>
<p>    End Sub<br />
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click<br />
        Me.Hide()<br />
        Home.Show()<br />
    End Sub</p>
<p>    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click<br />
        Dim adapter As SqlDataAdapter<br />
        Dim cmd As SqlCommand<br />
        Dim ds As New DataSet<br />
        Dim test As Boolean<br />
        Dim conn As SqlConnection</p>
<p>        Dim sql As String<br />
        conn = New SqlConnection(&#8220;Data Source=NASSQLEXPRESS;Database=data2;Integrated Security=True; Connect Timeout=30;&#8221;)</p>
<p>        sql = &#8220;Insert into SAdmission(RegistrationNo,Name,DateofBirth,Class,Nationality,MotherTongue,Religion,BloodGroup,SecondLanguage,Address1,Address2,PhoneNo,DateofJoining,FathersName,Occupation,MothersName,Occupation1)values(&#8221; &#8216;RegistrationNo’,&#8217;Name’,&#8217;DateofBirth’,&#8217;Class’,&#8217;Nationality’,&#8217;MotherTongue’,&#8217;Religion’,&#8217;BloodGroup’,&#8217;SecondLanguage’,&#8217;Address1′,’Address2′,’PhoneNo’,&#8217;DateofJoining’,&#8217;FathersName’,&#8217;Occupation’,&#8217;MothersName’,&#8217;Occupation1′&#8221;)&#8221;</p>
<p>        conn.Open()<br />
        MsgBox(&#8220;conection has open&#8221;)<br />
        test = conn.State    &#8216;to check the connection state<br />
        MsgBox(test)<br />
        cmd = New SqlCommand(sql, conn)<br />
        MessageBox.Show(cmd.CommandText.ToString())<br />
        adapter = New SqlDataAdapter<br />
        adapter.InsertCommand = cmd<br />
        adapter.Update(ds, &#8220;SAdmission&#8221;)<br />
        conn.Close()<br />
        MsgBox(&#8220;You have successflly updated&#8221;)</p>
<p>    End Sub</p>
<p>    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click<br />
        Me.Close()</p>
<p>    End Sub<br />
End Class<br />
Plz check</p>
<p>Shaz</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using memcached
Database Caching 3/10 queries in 0.035 seconds using memcached
Object Caching 337/343 objects using memcached

Served from: itknowledgeexchange.techtarget.com @ 2013-05-26 02:22:12 -->