Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I store source code lines in SQL Server Database and access it via DataSet
    primarykey
    data
    text
    <p>I want to store the following code into the database:</p> <pre><code>fun(...); int main() { fun(3, 7, -11.2, 0.66); return 0; } fun(...) { va_list ptr; int num; va_start(ptr, n); num = va_arg(ptr, int); printf("%d", num); } </code></pre> <p>and then get it back in the dataset and display on a page.</p> <p>As of now I have successfully stored the questions with <code>varchar(MAX)</code> datatype but when I try to get it in the dataset i get the following error:</p> <p><code>Failed To Enable Constraints. One Or More Rows Contain Values Violating Non-null, Unique, Or Foreign-key Constraints.</code></p> <p>I am doing this in a ASP.NET web application.</p> <p><strong>EDIT:</strong> Here is the Table definition of the table I am inserting the data into </p> <p><img src="https://i.stack.imgur.com/ocksk.png" alt="Database Definition"></p> <p>The query I am using to insert the data into the table:</p> <pre><code>con.ConnectionString = constr; cmd.Connection = con; cmd.CommandText = "insert into QuesTable values(@D1,@D2,@D3,@D4,@D5,@D6,@D7, NULL)"; cmd.Parameters.Add("@D1", SqlDbType.Int).Value = txtQID.Text; cmd.Parameters.Add("@D2", SqlDbType.VarChar).Value = txtques.Text; cmd.Parameters.Add("@D3", SqlDbType.VarChar).Value = txtansa.Text; cmd.Parameters.Add("@D4", SqlDbType.VarChar).Value = txtansb.Text; cmd.Parameters.Add("@D5", SqlDbType.VarChar).Value = txtansc.Text; cmd.Parameters.Add("@D6", SqlDbType.VarChar).Value = txtansd.Text; cmd.Parameters.Add("@D7", SqlDbType.VarChar).Value = txtcorr.Text; con.Open(); int i = cmd.ExecuteNonQuery(); con.Close(); </code></pre> <p>And finally the code by which I am extracting the data from the dataset</p> <pre><code>DataSet1.QuesTableDataTable dt = new DataSet1.QuesTableDataTable(); DataSet1TableAdapters.QuesTableTableAdapter adp = new DataSet1TableAdapters.QuesTableTableAdapter(); dt = adp.GetData(); DataTable dtUser = dt.Clone(); </code></pre> <p>Hope the information is helpful.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload