ASP.NET code not working in VisualStudio.NET

Created the following code in VS.NET modifying a block of code from a reference book wherein the author was using a simple text editor.


Sub InsertRecord()
Dim conClasf As OleDb.OleDbConnection
Dim cmdClasf As New OleDb.OleDbCommand
Dim strClasf As String
Dim strSQL As String
Dim intRowsAff As Integer
'-----------------
lblErrMsg.Text = ""
lblRecsAff.Text = ""
'-----------------
strClasf = "Provider = Microsoft.Jet.4.0.;" & _
"Data = " & _
Server.MapPath("classified.mdb") & ";"
conClasf = New OleDb.OleDbConnection(strClasf)
conClasf.Open() ' ---here..
'-----------------
Randomize()
strSQL = "INSERT INTO members (" & _
"memberid, " & _
"firstname, " & _
"lastname, " & _
"[password], " & _
"confnumber, " & _
"confirmed " & _
") VALUES ('" & _
Replace(txtMemberid.Value, "'", "''") & _
"', '" & _
Replace(txtFirstname.Value, "'", "''") & _
"', '" & _
Replace(txtLastname.Value, "'", "''") & _
"', '" & _
Replace(txtPassword.Value, "'", "''") & _
"', " & _
CLng(Rnd() * 9000000) + 1000000 & _
", " & _
"False)"
'---------------------
cmdClasf = New OleDb.OleDbCommand(strSQL, conClasf)
'---------------------
Try
intRowsAff = cmdClasf.ExecuteNonQuery()
Catch ex As Exception
lblErrMsg.Text = ex.Message
End Try
' ----------------------
lblRecsAff.Text = intRowsAff & " record(s) inserted"
conClasf.Close()
End Sub

When run, VS.NET found no problems. When Data was entered and submit button hit, the browser debugger came back with:
Exception Details: System.Data.OleDb.OleDbException: No error information available: REGDB_E_CLASSNOTREG(0x80040154).
Source Error:

Line 49: Server.MapPath("classified.mdb") & ";"
Line 50: conClasf = New OleDb.OleDbConnection(strClasf)
error--->Line 51: conClasf.Open()
Line 52: '-----------------
Line 53: Randomize()

What was wrong with conClasf.Open()
VS.NET demands that Open & Close have ().
0
TheoKron
4/30/2004 10:57:24 PM
asp.net.getting-started 91979 articles. 4 followers. Follow

2 Replies
386 Views

Similar Articles

[PageSpeed] 57

Your database drivers are probably not up-to-date. You can try installing  the latest version of MDAC and see what happens.

Now for the mean stuff. If you got this code from a reference book, well, I don't know who wrote this book, but you should probably find another one. This code seems to assume that replacing quotes with double quotes protects it from Sql Injection Attacks. Well, it's wrong, because there is a variety of methods to work around this.
The right way of injecting values into a sql query is to use Parameter objects.
Search this forum for "Sql injection attack" for more details.
Bertrand
----
This posting is provided "AS IS" with no warranties, and confers no rights.
0
bleroy
5/1/2004 12:13:41 AM
Thanks bleroy,

Drivers are up to date; the original code worked in web matrix. I had to adjust it for VS.NET. When it ran, the browser had no problem with the initial .aspx page. The problem arose when I hit the submit button. At this moment an exception was thrown on the conClasf.Open() line.
This line is the teh same as in original code except for the fact that VS.NET insists on puting () at the end of it.
0
TheoKron
5/1/2004 3:10:27 AM
Reply:

Similar Artilces:

Net:Net:Net::LDAP::FAQ
------_=_NextPart_001_01C6429F.D89AA417 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hello, Net::LDAP Net::LDAPS Is there a possible to LDAP bind with an encrypted (SHA, SSHA, CRYPT, ....) password? I don't like to write the secret password to the perl file. Best regards Barbara Wilbert ------_=_NextPart_001_01C6429F.D89AA417-- Wilbert Barbara (CI/OSI) * wrote: > Hello, > > Net::LDAP > Net::LDAPS > > Is there a possible to LDAP bind with an encrypted (SHA, SSHA, CRYPT, > ......

use VB.NET and C#.NET code in the same C#.NET project
All-- Here is a sample that is "off the beaten path", (at least for me). Is it possible, in an ASP.NET application, using the code-behind page building technique, to have both pages written in VB.NET and pages written C#.NET?At http://www.WebLogicArts.com/DemoList.aspx there is a sample that shows that, (contrary to popular belief), it IS possible to mix ASP.NET pages built with C#.NET with ASP.NET pages built with VB.NET in the same VS.NET 2003 project. Note that this is just a "fun" sample to see if it can be done and I do not recommend this practice as a "standard" way of develo...

Code works with .Net 1.1 but not .Net 2.0
Can anyone offer any suggestions as to why this code would work under .Net 1.1 and not .Net 2.0? I listed the error I receive below, also. Line 865. Thank you, Public Function GetAge(ByVal Birthdate As System.DateTime, _ Optional ByVal AsOf As System.DateTime = #1/1/1700#) _ As Integer Dim iMonths As Integer Dim iYears As Integer Dim dYears As Decimal Dim lDayOfBirth As Long Dim lAsOf As Long Dim iBirthMonth As Integer Dim iAsOFMonth As Integer If AsOf = "#1/1/1700#" ...

How to convert C#.Net code to VB.Net code ???...
HI, i was searching something new, then i suddenly find some tips to convert C#.Net code to VB.Net but i did not do well. i am puttint its url here plz tell me how to convert C#.Net code to VB.Net. http://www.dotnetspider.com/code/C-273-Convert-C-VB-NET.aspx Jasim...Please remember to click “Mark as Answer” on the post that helps youJasim AkhtarNew Delhi ( INDIA ) It would be better if you write the problem you having, while converting from C# to VB.NET. You cannot completely rely on online converters. ThanksMark post(s) as "Answer" that helped youElectronic ScrewWebsite||Bl...

Translate c#.net code to vb.net code
Hi I can usually do the translation myself, but this time I am a bit stumped  Let us consider to rewrite Urls (more than 16000 links) using a table. Save original url and rewritten url in a table. Now add a class file in App_Code folder. class UrlRewriteModule : IHttpModule{    public void Dispose()    {        // Nothing to dispose    }    public void Init(HttpApplication context)    {        context.BeginRequest += new EventHandler(context...

Converting classic to .NET 2 code, and .NET gets an error back from ADS?
 For future-proofing, our Internal Phone Directory is being moved onto our AD servers, and obviously we're using LDAP for queries.To get the phoneboook queries working, I adapted the current classic ASP code to use LDAP, and that works fine. However, we're wanting to move these pages to .NET, and that's where the problem comes in. Using the same basic logic from the Classic code (90% of its unchanged) to produce an LDAP query, I get the error  155 Unknown error (0x80005000)This is using the same website, and so the same credentials  - unless aspx pages run und...

Differences between .net 1, .net 1.1, .net 2.0 and .net 3.0
Hi, This seems to be a common question, but i havent got an answer yet:(Can, any one please explain me the differences between these versions.If you keep your feet firmly on the ground, you'll have trouble putting on your pants! Have a look into this links http://en.wikipedia.org/wiki/.NET_Framework http://blogs.msdn.com/mohammadakif/archive/2006/12/03/net-3-0-different-versions-of-the-net-framework.aspx http://www.codeproject.com/aspnet/ComparisonASP1xASP20.aspAshok Rajawww.iGold.inDon't forget to click "Mark as Answer" on the post that helped you. This credits that m...

converting to vb.net from c#.net authorize.net
authorize.net offered me some sample code when I signed up with them the only problem is the sample code is in c#.net but my page that they type all of their credit card into is vb.net <code><%@ Import Namespace="System.Net" %> <%@ Import Namespace="System.IO" %> <script language="C#" runat="server"> void Page_Load(Object Src, EventArgs E) { myPage.Text = readHtmlPage("https://certification.authorize.net/gateway/transact.dll"); } private String readHtmlPage(string url) { ...

Net Farmers net
Has anyone been able to access any of the tests at http://suicide.netfarmers.net ? I can get the default page but none of the tests appear to be operating over the last several weeks. -- CK I just tested and works as usual!!!Every session TCP_error,because my Shields_guard is intact<<G>> -- Regard: Joh@nnes� 1216771 Ont.Inc. "Nothing is more damaging to a new truth than an old error" "CK" <ckphalon@lascenltd.com> wrote in message news:9i45gg$1qa9$1@news.grc.com... : Has anyone been able to access any of the tests at : http://suicide...

Sending SMS using vb.net or C#.net using vb.net or c#.net
Hi  My requirement is I hav one csv file with these fields id,mobilenum,messgae,status.intiallu staus is 0. once i read the all fileds and take that mobile number.using tat mobile number  i need to send sms .after sending sms i shuld change status as 1 How to send sms thru coding (please dont provide any links.if it is provide also please give working links becox i checked codeproject .i didnt get any nice link. and also provide the how to update the status field im csv file   Thank ssandhya   To send SMS, you need some third party SMS providers. if you consul...

net send in .net
Hi,  I am trying to execute net send comman in my vb.net code. But I am getting "win32 exception unhandled error". Please help me. My code is:Dim psi As New ProcessStartInfo() psi.UseShellExecute = False psi.FileName = "Net send" 'xxx.xxx.xx.xx  - IP address of a system in my network psi.Arguments = "xxx.xxx.xx.xx test" Process.Start(psi)  Thanks in advance! Shwetha Tryu changing   psi.FileName = "Net send" 'xxx.xxx.xx.xx  - IP address of a system in my network psi.Arguments = "xxx.xxx.xx.xx test&quo...

To .NET or not .NET, that is the question
I'm running WinXP pro 32-bit, meaning I've got the version 1-dot-something of .NET that XP came with. I've been looking for various softwares, and more and more often come across .NET version 2 being prerequisite. No urgency for me re. my questions to this group - so far I have just decided to hit the red X on those download pages - but the desire for this newer version of .NET seems to be growing for me. Firstly, according to my (limited) research, newer .NET versions are inclusive of the previous ones, and the current version seems to be 3.5. So if I go for i...

Starting an Ajax.net Application in .net
i am new to ajax.net could any one give me simple ajax,net example so that i start building on my ajax skills please.........  I started with the todolist video on the main asp.net/ajax page, and its all you need to know to get started. http://download.microsoft.com/download/0/f/6/0f651a0f-6f2b-4497-b061-e1b2825e22e0/MSAJAX-ToDoList.wmv Don't forget to click "Mark as Answer" on the post that helped you.This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped. http://asp.net/ajax/    ...

Differences between .net 1, .net 1.1, .net 2.0 and .net 3.0 #2
Hi, This seems to be a common question, but i havent got an answer yet:(Can, any one please explain me the differences between these versions.If you keep your feet firmly on the ground, you'll have trouble putting on your pants! There are too many differences for one email - - from 1.0 to 1.1 (not a whole lot of real change, other than fixes, at least compared to 1.1 to 2.0) With 2.0, there were many new declarative controls, with many new ideas added in With 3.0, it's a superset of 2.0 - instead of replacing the installation completely, it just 'added on' new functionality - I would...

vb.net vs c#.net vs j#.net
just out of curiousity which looks, acts most like java? i'm still learning trying to used to vb.net but it seems that it was easier to do some stuff with java. C# is Java++ in my opinion. If you have done C or Jave you will prefer C#.Mike Schellenberger - MCAD If you are looking for language similar to java go for J#. However most code samples you find on the net will be in VB.NET and C#....

Web resources about - ASP.NET code not working in VisualStudio.NET - asp.net.getting-started

VisualStudio Cordova (@VSCordovaTools) on Twitter
Log in Sign up To bring you Twitter, we and our partners use cookies on our and other websites. Cookies help personalize Twitter content, tailor ...

Visual Studio - YouTube
... We'll be sharing useful and insightful videos around ALM, developers, and tutorials. Follow our social channels: http://www.facebook.com/vi ...

Diff File made easy with VisualStudio 11
In my previous post I’ve been critic on the Visual Studio 11 Beta greyed UI (and especially greyed icons!!). Let’s be positive, and frankly it ...

tfsdeleteproject.exe on VisualStudio.com
... in the last few days and had to look it up each time, I will record it here for posterity. Need to delete a Team Project you created on VisualStudio.com? ...

VisualStudio Engadget
Back to Mobile View Engadget for Windows Phone 7 - get the app now! AOL MAIL Engadget Classic Mobile HD ALT ENGADGET U.S. ESPAGÑOL ???? ???? ...

Followers · VisualStudio · Storify
Create stories using social media. Turn what people post on social media into compelling stories. Collect the best photos, video, tweets and ...

Is SAP Business ByDesign affordable and would you choose it anyway?
SAP has a reputation for being expensive. Even at $149/user/month for a minimum of 25 users Business ByDesign still weighs in at $44,700 per ...

Big Boy and Big Girl Coding
I read “Microsoft’s Top Developers Prefer Old-Schoool Coding Methods” and compared that information with my Google research. I won’t bore you ...

Latest Updates
Latest Updates - Free source code and tutorials for Software developers and Architects.; Updated: 15 Feb 2013

Blogs - Critical Thought Games
Not everything goes as planned, but I like to fix bugs fast. Especially bad ones. The WP7 version of geoDefense has a bad bug in it which causes ...

Resources last updated: 1/1/2016 10:17:11 AM