954,593 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Data Type MisMatch in Insert Statement with SqlDataSource

Hey everyone,
I'm fairly new to .Net and I am just starting to write some queries to begin using my database files, and I keep running into these errors. I have stepped through numerous tutorials and reference guides and still cannot seem to get things working properly. Basically I have a very basic database table im trying to store some information in using the follow code. I will show the web.config code for my connection as well as the query itself and where the query is getting called. Please let me know if anyone can be of assistance.
Thank you,
Nick G
Web.Config

<connectionStrings>
    <add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"
      providerName="System.Data.SqlClient" />
    <add name="DataConnectionString" connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|DevInquiry.accdb;"
      providerName="System.Data.OleDb"/>
  </connectionStrings>


SqlDataSource Declaration;
I placed this inside the <asp:SqlDataSource ID="InsertPatInfo" runat="server" ConnectionString="<%$ ConnectionStrings:DataConnectionString %>"
providername="<%$ ConnectionStrings:DataConnectionString.ProviderName %>"
InsertCommand = "Insert into tblPatInfo(PatID, PatName, PatAge, PatState, PatCountry, PatPhone, PatCell) VALUES
('',@PatName, @PatAge, @PatState, @PatCountry, @PatPhone, @PatCell)">
<InsertParameters>
<asp:ControlParameter ControlID = "PatInfoName" Name="PatName" PropertyName="text"/>
<asp:ControlParameter ControlID = "PatInfoAge" Name="PatAge" PropertyName="text" />
<asp:ControlParameter ControlID = "PatInfoState" Name="PatState" PropertyName="selectedvalue" />
<asp:ControlParameter ControlID = "PatInfoCountry" Name="PatCountry" PropertyName="selectedvalue" />
<asp:ControlParameter ControlID = "PatInfoPhone" Name="PatPhone" PropertyName = "text" />
<asp:ControlParameter ControlID = "PatInfoCell" Name="PatCell" PropertyName="Text" />
</InsertParameters>
</asp:SqlDataSource>


Here is the call to the statement.
InsertPatInfo.Insert() ; thrown after a button is clicked.

nickg21
Newbie Poster
14 posts since Nov 2011
Reputation Points: 10
Solved Threads: 0
 

I figured it out, I didn't realize that you weren't supposed to declare the Auto-Increment primary keys, i've been coding PHP for too long, and used the wrong syntax

nickg21
Newbie Poster
14 posts since Nov 2011
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: