Solved

How do i change this insert from into a access db to an sql in asp.net

Posted on 2004-03-29
1
129 Views
Last Modified: 2012-05-04
I have the below code inserting data into an access database nit I not sure what needed to be changed to make it insert the data into an sql db.

Dim strConn as string ="PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & server.mappath("db/emails.mdb") & ";"
Dim conn As New OLEDBConnection(strConn)
Dim cmdinsert As OLEDBCommand

cmdInsert = New OLEDBCommand("Insert into emaildet (name, email) VALUES ('" + Request.Params("name") + "','" + Request.Params("email") + "')", conn)
conn.Open()
cmdInsert.ExecuteNonQuery()
conn.close

Thanks in advance
0
Comment
Question by:dexine
1 Comment
 
LVL 35

Accepted Solution

by:
YZlat earned 125 total points
ID: 10710132
Dim strConn as string ="PROVIDER=SQLOLEDB;DATA SOURCE=sqlservername;UID=username;PWD=password;DATABASE=databasename "

Dim conn As New SQLConnection(strConn)
Dim cmdinsert As SQLCommand

cmdInsert = New SQLCommand("Insert into emaildet (name, email) VALUES ('" + Request.Params("name") + "','" + Request.Params("email") + "')", conn)
conn.Open()
cmdInsert.ExecuteNonQuery()
conn.close

0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
css help 3 121
replace quotes with UTF-8 character 38 95
Problem to echo 6 95
Problem to file 3 74
Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
The viewer will learn how to count occurrences of each item in an array.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question