0

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.

1
Contributor
1
Reply
2
Views
5 Years
Discussion Span
Last Post by nickg21
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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.