|
-
Feb 3rd, 2011, 01:14 AM
#1
Thread Starter
Lively Member
ASP & SQL Writing (Microsoft SQL Server 2008)
Hello,
How can I insert the First Name & Last Name TextBox Data into the database?
Code:
<html>
<head>
<title>New Member - OBMFO</title>
</head>
<body>
Your first name is
<%
FirstName = request("firstname")
response.write FirstName + " "
LastName = request("lastname")
response.write LastName
%>
<%
ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Registration;Data Source=KAWSERHOSSAIN\SQLEXPRESS"
SQL = "INSERT INTO [Registration Table] (First) VALUES ('Hello World')"
%>
</body>
</html>
Please HELP Thanks
Last edited by Kawser; Feb 3rd, 2011 at 01:18 AM.
-
Feb 3rd, 2011, 08:01 AM
#2
Re: ASP & SQL Writing (Microsoft SQL Server 2008)
This should get you pretty close
Code:
<html>
<head>
<title>New Member - OBMFO</title>
</head>
<body>
Your first name is
<%
FirstName = request("firstname")
response.write FirstName + " "
LastName = request("lastname")
response.write LastName
ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Registration;Data Source=KAWSERHOSSAIN\SQLEXPRESS"
SQL = "INSERT INTO [Registration Table] (First, Last) VALUES ('" & FirstName "', '" & LastName & "')"
Set Cn = Server.CreateObject("ADODB.Connection")
Cn.Open
Cn.Execute SQL
Cn.Close
Set Cn = Nothing
%>
</body>
</html>
-
Feb 3rd, 2011, 12:50 PM
#3
Thread Starter
Lively Member
Re: ASP & SQL Writing (Microsoft SQL Server 2008)
 Originally Posted by MarkT
This should get you pretty close
Code:
<html>
<head>
<title>New Member - OBMFO</title>
</head>
<body>
Your first name is
<%
FirstName = request("firstname")
response.write FirstName + " "
LastName = request("lastname")
response.write LastName
ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Registration;Data Source=KAWSERHOSSAIN\SQLEXPRESS"
SQL = "INSERT INTO [Registration Table] (First, Last) VALUES ('" & FirstName "', '" & LastName & "')"
Set Cn = Server.CreateObject("ADODB.Connection")
Cn.Open
Cn.Execute SQL
Cn.Close
Set Cn = Nothing
%>
</body>
</html>
Thank you so much for you help MarkT,
BUT
I get this error:
"An error occurred on the server when processing the URL. Please contact the system administrator.
If you are the system administrator please click here to find out more about this error."
-
Feb 3rd, 2011, 01:05 PM
#4
Re: ASP & SQL Writing (Microsoft SQL Server 2008)
It looks like I may have missed an ampersand. Try using this line instead.
SQL = "INSERT INTO [Registration Table] (First, Last) VALUES ('" & FirstName & "', '" & LastName & "')"
Also make sure the field names you are inserting into are correct.
-
Feb 3rd, 2011, 01:07 PM
#5
Thread Starter
Lively Member
Re: ASP & SQL Writing (Microsoft SQL Server 2008)
 Originally Posted by MarkT
It looks like I may have missed an ampersand. Try using this line instead.
SQL = "INSERT INTO [Registration Table] (First, Last) VALUES ('" & FirstName & "', '" & LastName & "')"
MarkT
Yes I noticed that and fixed it, but I still get the error 
Thanks.
-
Feb 3rd, 2011, 01:10 PM
#6
Thread Starter
Lively Member
Re: ASP & SQL Writing (Microsoft SQL Server 2008)
MarkT,
I have a better error msg
"Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
/Admin/NewMember.asp, line 23 "
Thanks Again.
-
Feb 3rd, 2011, 01:12 PM
#7
Re: ASP & SQL Writing (Microsoft SQL Server 2008)
All I can recommend is you comment out all the script lines and try loading the page. Then uncomment the lines one at a time until you find the line that is causing the problem.
-
Feb 3rd, 2011, 01:16 PM
#8
Re: ASP & SQL Writing (Microsoft SQL Server 2008)
 Originally Posted by Kawser
MarkT,
I have a better error msg
"Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
/Admin/NewMember.asp, line 23 "
Thanks Again.
That could be a number of things. See if this link helps. http://support.microsoft.com/kb/306345
-
Feb 3rd, 2011, 01:17 PM
#9
Thread Starter
Lively Member
Re: ASP & SQL Writing (Microsoft SQL Server 2008)
These Lines Are Causing the Problem:
Cn.Open
Cn.Execute SQL
Cn.Close
Set Cn = Nothing
Thanks.
-
Feb 3rd, 2011, 05:52 PM
#10
Hyperactive Member
Re: ASP & SQL Writing (Microsoft SQL Server 2008)
Hello,
Misinterpretation I beleive has occurred here.
Code:
cn.ConnectionString = ConnectionString
part of the neccessary connection object is the connection string property. Pass it a string and it works.
Kind regards
Steve
-
Feb 3rd, 2011, 07:11 PM
#11
Re: ASP & SQL Writing (Microsoft SQL Server 2008)
How did I miss that? That would make a big difference.
Kawser - In case you don't know the syntax, setting the ConnectionString would go between creating the connection object and openning it. I would also consider changing the name of your ConnectionString variable.
Set Cn = Server.CreateObject("ADODB.Connection")
cn.ConnectionString = ConnectionString
Cn.Open
-
Feb 3rd, 2011, 08:39 PM
#12
Thread Starter
Lively Member
Re: ASP & SQL Writing (Microsoft SQL Server 2008)
sparbag -> Thank You So Much for pointing this out.
MarkT -> Now I get this error:
Microsoft OLE DB Provider for SQL Server error '80004005'
Cannot open database "Registration" requested by the login. The login failed.
/Admin/NewMember.asp, line 24
I am using Windows Authentication Mode with no Password.
I tried changing the Security Info=False, but still no luck.
I have the code as follows:
Code:
<html>
<head>
<title>New Member - OBMFO</title>
</head>
<body>
DONE !
<%
FirstName = request("firstname")
response.write FirstName + " "
LastName = request("lastname")
response.write LastName
ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Registration;Data Source=KAWSERHOSSAIN\SQLEXPRESS"
SQL = "INSERT INTO [Registration Table] (First, Last) VALUES ('" & FirstName & "', '" & LastName & "')"
Set Cn = Server.CreateObject("ADODB.Connection")
cn.ConnectionString = ConnectionString
Cn.Open
Cn.Execute SQL
Cn.Close
Set Cn = Nothing
%>
</body>
</html>
THANKS A LOT.
-
Feb 3rd, 2011, 08:52 PM
#13
Thread Starter
Lively Member
Re: ASP & SQL Writing (Microsoft SQL Server 2008)
I change Integrated Security=True now I am getting this error 
Provider error '80040e21'
Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.
/Admin/NewMember.asp, line 24
Thanks for your help really appreciate it.
-
Feb 4th, 2011, 08:18 AM
#14
Re: ASP & SQL Writing (Microsoft SQL Server 2008)
Try Creating and Configuring a Universal Data Link (.udl) File. Once you have a connection working with that, open the file in notepad and get the correct ConnectionString.
-
Feb 4th, 2011, 12:37 PM
#15
Thread Starter
Lively Member
Re: ASP & SQL Writing (Microsoft SQL Server 2008)
 Originally Posted by MarkT
MarkT,
That's were I got the ConnectionString from in the first place.
-
Feb 4th, 2011, 01:42 PM
#16
Re: ASP & SQL Writing (Microsoft SQL Server 2008)
The UDL file is going to use the credentials you are currently logged in with when it tests a connection with the use Integrated Security option selected. When your ASP APP is trying to connect it is probably trying to pass the ASP Default User Account. In IIS 6 this would probably be IUSR_<ComputerName>.
I would try setting up your UDL with a username and password and then test that connection string in you asp code. I would guess the asp account that is trying to open the database doesn't have permissions to do so.
-
Feb 4th, 2011, 04:14 PM
#17
Thread Starter
Lively Member
Re: ASP & SQL Writing (Microsoft SQL Server 2008)
Hello MarkT,
I tried setting a UserName & Passoword but I get this error:

BTW: I am using IIS7.
Thanks.
-
Feb 4th, 2011, 04:53 PM
#18
Re: ASP & SQL Writing (Microsoft SQL Server 2008)
Is there really a user account name test? Have you tried the username and password you log in with?
-
Feb 4th, 2011, 05:02 PM
#19
Thread Starter
Lively Member
Re: ASP & SQL Writing (Microsoft SQL Server 2008)
 Originally Posted by MarkT
Is there really a user account name test? Have you tried the username and password you log in with?
I log in without any password on Windows & on the Server.
Look here I used all the username and passowd here but still no luck 

Thanks MarkT I really appreciate it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|