DeveloperBarn Forums

DeveloperBarn

Programming & IT forum

mdb to SQL SERVER

This is a discussion on mdb to SQL SERVER within the ASP Development forums, part of the Programming & Scripting category; i have a connection: Code: <!--#include file="adovbs.inc"--> <% Response.Expires = -1500 Response.Buffer = true Server.ScriptTimeout = 100 Session.Timeout = 90 ...

Go Back   DeveloperBarn Forums > Programming & Scripting > ASP Development

  #1  
Old July 9th, 2009, 06:33 AM
Centurion's Avatar
Barn Enthusiast
 
Join Date: Dec 2008
Posts: 322
Rep Power: 2
Centurion is on a distinguished road
Default mdb to SQL SERVER

i have a connection:

Code:
<!--#include file="adovbs.inc"-->

<%
Response.Expires = -1500
Response.Buffer = true
Server.ScriptTimeout = 100
Session.Timeout = 90



			'Create an ADO connection object
			set conn=Server.CreateObject("ADODB.Connection")
			strSQLServerName = "XXXXXXX" 'Holds the name of the SQL Server (This is the name/location or IP address of the SQL Server)
			strSQLDBUserName = "SA" 'Holds the user name (for SQL Server Authentication)
			strSQLDBPassword = "test" 'Holds the password (for SQL Server Authentication)
			strSQLDBName = "db2SQL" 
			
				'Initilise the DB Connection String
			conn.open = "provider=SQLOLEDB; Server=" & strSQLServerName & ";User ID=" & strSQLDBUserName & ";Password=" & strSQLDBPassword & ";Database=" & strSQLDBName & ";"
		
%>
and i have this code below which is working with an access database.. my problem is, i have tryed changing cn to conn but it still doesnt work.. could anyone suggest what i should do? or help me code this? pretty please

Code:
<%
Dim submit1, oldpassword, newpassword, confirmpassword
submit1 = Server.HTMLEncode(Request.Form("submit1"))
oldpassword = Request.Form("oldpassword")
newpassword = Request.Form("newpassword")
confirmpassword = Request.Form("confirmpassword")
'If submit1 = "confirmpassword" Then
 Dim sc, cn, rs, sql
 
 sc = "driver={Microsoft Access Driver (*.mdb)};dbq=" _
 & Server.MapPath("../DB/H2.mdb")
 
 Set cn = Server.CreateObject("ADODB.Connection")
 
 Set rs = Server.CreateObject("ADODB.Recordset")
 
 cn.Open conn
 
 sql = "SELECT [password] FROM [member] " _
  & "WHERE [username] = '" & Request.Form("username") & "'"


 rs.Open sql, cn, 1
 
 If oldpassword = "" Or newpassword = "" Then
  Response.Write "Make sure password is valid and fill all the fields please!"
 ElseIf rs("password") <> oldpassword Then
  Response.Write "Wrong password inserted!"
 ElseIf newpassword <> confirmpassword Then
  Response.Write "Confirm password and new password are not the same!"
 ElseIf oldpassword = newpassword Then
  Response.Write "Old password and new password are the same!"
 Else
    
    sql = "UPDATE mem SET password = '" & newpassword & "' WHERE " _
  & "username = '" & Request.Form("username") & "'"

  cn.Execute(sql)
  Response.Write "Your Password has been changed!"
 End If
 rs.Close
 Set rs = Nothing
 cn.Close
 conn.close
 Set cn = Nothing
'End If
%>
Reply With Quote
  #2  
Old July 9th, 2009, 07:19 AM
micky's Avatar
Lazy Bum
 
Join Date: Jul 2008
Location: India
Posts: 563
Rep Power: 4
micky has a spectacular aura aboutmicky has a spectacular aura aboutmicky has a spectacular aura about
Default

Have you included the connection file or is it on the same page??

Also do you get any error?
If yes what is it?
__________________
Get the Mantra!
Reply With Quote
  #3  
Old July 9th, 2009, 07:32 AM
Centurion's Avatar
Barn Enthusiast
 
Join Date: Dec 2008
Posts: 322
Rep Power: 2
Centurion is on a distinguished road
Default

Quote:
Originally Posted by micky View Post
Have you included the connection file or is it on the same page??

Also do you get any error?
If yes what is it?
the connection file is included in the page.. and the line in the connection file is called "Conn"

the connection is to a sql server database.
Reply With Quote
  #4  
Old July 9th, 2009, 07:53 AM
jmurrayhead's Avatar
The Barnfather
 
Join Date: Mar 2008
Real name: Jason
Location: Washington, D.C.
Posts: 1,915
Blog Entries: 7
Rep Power: 13
jmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud of
Default

We'll need more info than that...what happens when you try to run the code. Also, you will have to change all the variables to either cn or conn. You can't have both.

Comments on this post
Centurion agrees: Thanked Post
__________________
jmurrayhead
If you agree with me... click the icon!
If my post solved your problem, click the button in the lower right-hand corner of the post.

If you like it here...throw us a few bones to help
support us.

Join our Folding team: DeveloperBarn Folding

Reply With Quote
The Following User Says Thank You to jmurrayhead For This Useful Post:
Centurion (July 9th, 2009)
  #5  
Old July 9th, 2009, 07:57 AM
Centurion's Avatar
Barn Enthusiast
 
Join Date: Dec 2008
Posts: 322
Rep Power: 2
Centurion is on a distinguished road
Default

Quote:
Originally Posted by jmurrayhead View Post
We'll need more info than that...what happens when you try to run the code. Also, you will have to change all the variables to either cn or conn. You can't have both.
i have changed cn to conn :

Code:
<%
Dim submit1, oldpassword, newpassword, confirmpassword
submit1 = Server.HTMLEncode(Request.Form("submit1"))
oldpassword = Request.Form("oldpassword")
newpassword = Request.Form("newpassword")
confirmpassword = Request.Form("confirmpassword")
'If submit1 = "confirmpassword" Then
 Dim sc, conn, rs, sql
 
' sc = "driver={Microsoft Access Driver (*.mdb)};dbq=" _
' & Server.MapPath("../DB/H2.mdb")
 
 Set conn = Server.CreateObject("ADODB.Connection")
 
 Set rs = Server.CreateObject("ADODB.Recordset")
 
 conn.Open conn
 
 sql = "SELECT [password] FROM [member] " _
  & "WHERE [username] = '" & Request.Form("username") & "'"


 rs.Open sql, conn, 1
 
 If oldpassword = "" Or newpassword = "" Then
  Response.Write "Make sure password is valid and fill all the fields please!"
 ElseIf rs("password") <> oldpassword Then
  Response.Write "Wrong password inserted!"
 ElseIf newpassword <> confirmpassword Then
  Response.Write "Confirm password and new password are not the same!"
 ElseIf oldpassword = newpassword Then
  Response.Write "Old password and new password are the same!"
 Else
    
    sql = "UPDATE mem SET password = '" & newpassword & "' WHERE " _
  & "username = '" & Request.Form("username") & "'"

  conn.Execute(sql)
  Response.Write "Your Password has been changed!"
 End If
 rs.Close
 Set rs = Nothing
 conn.Close
 conn.close
 Set conn = Nothing
'End If
%>
and the error i get is..:

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
/changep3.asp, line 23


line 23 is :

Code:
 conn.Open conn
Reply With Quote
  #6  
Old July 9th, 2009, 08:14 AM
jmurrayhead's Avatar
The Barnfather
 
Join Date: Mar 2008
Real name: Jason
Location: Washington, D.C.
Posts: 1,915
Blog Entries: 7
Rep Power: 13
jmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud of
Default

I would take a look here: ConnectionStrings.com - Forgot that connection string? Get it here! and try the various connection strings they have for SQL Server. It seems it is unable to find the data source (SQL Server). Be sure your strSQLServerName variable contains the right address/ IP of your SQL Server.
Reply With Quote
  #7  
Old July 9th, 2009, 08:47 AM
mehere's Avatar
Super Sarcasm Mistress
 
Join Date: Mar 2008
Real name: Joanne
Location: Wide Awake In Dreamland
Posts: 365
Rep Power: 6
mehere is just really nicemehere is just really nicemehere is just really nicemehere is just really nicemehere is just really nice
Default

maybe it's me, but i don't even see a connection string to SQL ... the only one i see, is the one to Access and that one is commented out.
__________________
Quote of the Month:
Mistakes: It could be that the purpose of your life is only to serve as a warning to others.

Questions to Ponder:
Why do banks charge you a "non-sufficient funds fee" on money they already know you don't have?

iif([sarcasm]=true,iif([you have to ask]=true,"didn't work","ha ha ha"),"not sarcasm")
copyright © 2008 sbenj69

Sarchasm: The gulf between the author of sarcastic wit and the person who doesn't get it.
Reply With Quote
  #8  
Old July 9th, 2009, 09:31 AM
Centurion's Avatar
Barn Enthusiast
 
Join Date: Dec 2008
Posts: 322
Rep Power: 2
Centurion is on a distinguished road
Default

Quote:
Originally Posted by mehere View Post
maybe it's me, but i don't even see a connection string to SQL ... the only one i see, is the one to Access and that one is commented out.
the include file contains the connection.

when i did ..

cn = conn

it crashed
Reply With Quote
  #9  
Old July 9th, 2009, 09:43 AM
Wolffy's Avatar
Wolfmaster
 
Join Date: Mar 2008
Real name: Wolff
Location: Peoria, IL
Posts: 767
Blog Entries: 1
Rep Power: 8
Wolffy is a splendid one to beholdWolffy is a splendid one to beholdWolffy is a splendid one to beholdWolffy is a splendid one to beholdWolffy is a splendid one to beholdWolffy is a splendid one to behold
Default

Well, the problem is probably with the connection string. Without seeing that, we can't really help much.
__________________
Wolffy
------------------------
Opinions expressed are my own and do not necessity reflect those of any sane person. Any code provided is intended to be an example and is provided AS IS. Rework for your specific environment may be required. Void where prohibited by law. Not valid in California. Your mileage may vary.
Reply With Quote
  #10  
Old July 9th, 2009, 09:49 AM
Centurion's Avatar
Barn Enthusiast
 
Join Date: Dec 2008
Posts: 322
Rep Power: 2
Centurion is on a distinguished road
Default

Quote:
Originally Posted by Wolffy View Post
Well, the problem is probably with the connection string. Without seeing that, we can't really help much.
the connection string was in my first post!...
Reply With Quote
Reply

  DeveloperBarn Forums > Programming & Scripting > ASP Development

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads

Thread Thread Starter Forum Replies Last Post
SQL Server Integration Services guddu Microsoft SQL Server 1 April 24th, 2009 07:08 AM
SQL Server CREATE TABLE..LIKE Wolffy SQL Code Samples 2 March 12th, 2009 04:51 PM
SQL Server 2008 stephenhy88 Microsoft SQL Server 7 August 13th, 2008 01:55 AM
SQL Server Views theChris Microsoft SQL Server 3 March 23rd, 2008 07:35 PM


All times are GMT -4. The time now is 02:04 AM.


Copyright ©2008-2009, DeveloperBarn

Content Relevant URLs by vBSEO 3.3.2