Avatar of TechMonster
 asked on

write to sql database using asp.net

My mind is having a hard time just getting started using ADO.NET.  I am using Sharepoint designer so all I have is just a aspx page.  

How would I use ado.net to write a text field to a database?  There are several code examples but none seem to be the correct syntex I need for the below code.

<%@ Page Language="C#" %>

<html dir="ltr" xmlns:mso="urn:schemas-microsoft-com:office:office" xmlns:msdt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882">

<head runat="server">
<META name="WebPartPageExpansion" content="full">
<!--[if gte mso 9]><xml>
<mso:PublishingContactPicture msdt:dt="string">, </mso:PublishingContactPicture><mso:PublishingContact msdt:dt="string"></mso:PublishingContact></mso:CustomDocumentProperties></xml><![endif]-->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled 1</title>



<label id="lblFirstName">First Name </label> <textarea name="txtFirstName" id="txtFirstName"></textarea>
<label id="lblLastName">Last Name </label> <textarea name="txtLastName" id="txtLastName"></textarea>
<label id="lblAnswer">Answer </label> <textarea name="txtAnswer" id="txtAnswer"></textarea>
<label id="lblOpt">Selected Option</label> <textarea name="txtOpt" id="txtOpt"></textarea>

<SCRIPT type ="text/javascript">
function qs() {
	var qsParm=new Array();
      var query = window.location.search.substring(1);
      var parms = query.split('&');
      for (var indx=0; indx<parms.length; indx++) {
            var pos = parms[indx].indexOf('=');
            if (pos > 0) {
                  var key = parms[indx].substring(0,pos);
                  var val = parms[indx].substring(pos+1);
                  qsParm[key] = val;
      return qsParm;

var info=qs();

var firstname = info['fn'];
var lastname = info['ln'];
var ans = info['ans'];
var opt = info['opt'];

document.getElementById("txtFirstName").value = firstname;
document.getElementById("txtLastName").value = lastname;
document.getElementById("txtAnswer").value = ans;
document.getElementById("txtOpt").value = opt;



Open in new window

ASP.NETMicrosoft SharePointJavaScript

Avatar of undefined
Last Comment

8/22/2022 - Mon

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

I was hoping for some more detailed code.  I actuall was able to find my solution through other means but the one posted above works as well.

Thanks for the response
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes