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:content tags, at the bottom of the page, I dont know if this is correct.

<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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.