Solved

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

Posted on 2004-03-29
1
128 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

930 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now