473,797 Members | 3,212 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Change code to work with OLEDB

Can someone please tell me how I edit this code so it works with an OleDB...

Thanks

Sub Application_Aut henticateReques t(ByVal sender As Object, ByVal e As
EventArgs)
' Fires upon attempting to authenticate the use
If Request.IsAuthe nticated Then
'Determine this user's roles
Dim reader As OleDbDataReader
reader =
SqlHelper.Execu teReader(Config urationSettings .AppSettings("s trConn"),
CommandType.Sto redProcedure, "rolesForUs er", New OleDbParameter( "@Username" ,
User.Identity.N ame))

' Create an array of role names
Dim roleList As New ArrayList
Do While reader.Read()
roleList.Add(re ader("Name"))
Loop
reader.Close()

'Convert the roleList ArrayList to a String array
Dim roleListArray As String() = roleList.ToArra y(GetType(Strin g))

'Add the roles to the User Principal
HttpContext.Cur rent.User = _
New
System.Security .Principal.Gene ricPrincipal(Us er.Identity, roleListArray)
End If
End Sub
Jun 12 '06 #1
2 1240
Where are you getting the error?
Patrick
"Tim::.." <myatix_at_hotm ail.com> wrote in message
news:6B******** *************** ***********@mic rosoft.com...
Can someone please tell me how I edit this code so it works with an
OleDB...

Thanks

Sub Application_Aut henticateReques t(ByVal sender As Object, ByVal e As
EventArgs)
' Fires upon attempting to authenticate the use
If Request.IsAuthe nticated Then
'Determine this user's roles
Dim reader As OleDbDataReader
reader =
SqlHelper.Execu teReader(Config urationSettings .AppSettings("s trConn"),
CommandType.Sto redProcedure, "rolesForUs er", New
OleDbParameter( "@Username" ,
User.Identity.N ame))

' Create an array of role names
Dim roleList As New ArrayList
Do While reader.Read()
roleList.Add(re ader("Name"))
Loop
reader.Close()

'Convert the roleList ArrayList to a String array
Dim roleListArray As String() =
roleList.ToArra y(GetType(Strin g))

'Add the roles to the User Principal
HttpContext.Cur rent.User = _
New
System.Security .Principal.Gene ricPrincipal(Us er.Identity, roleListArray)
End If
End Sub

Jun 12 '06 #2
There is no error as such!

You just can't use SQLHelper object with OleDB connection So I was wondering
how else it could be done!

Here is what I'm working on!

Sub Application_Aut henticateReques t(ByVal sender As Object, ByVal e As
EventArgs)
' Fires upon attempting to authenticate the use
If Request.IsAuthe nticated Then

Dim objConn
Dim cmd As OleDbCommand
Dim strSQL As String

strSQL = "SELECT group FROM persons = @Username"

objConn = New
OleDbConnection (ConfigurationS ettings.AppSett ings("strConn") )
cmd = New OleDbCommand(st rSQL, objConn)

'Determine this user's roles
Dim reader As OleDbDataReader
cmd.Parameters. Add("@Username" , User.Identity.N ame)
reader = cmd.ExecuteRead er
' Create an array of role names
Dim roleList As New ArrayList
Do While reader.Read()
roleList.Add(re ader("Name"))
Loop
reader.Close()

'Convert the roleList ArrayList to a String array
Dim roleListArray As String() = roleList.ToArra y(GetType(Strin g))

'Add the roles to the User Principal
HttpContext.Cur rent.User = _
New
System.Security .Principal.Gene ricPrincipal(Us er.Identity, roleListArray)
End If
End Sub

"Patrick.O. Ige" wrote:
Where are you getting the error?
Patrick
"Tim::.." <myatix_at_hotm ail.com> wrote in message
news:6B******** *************** ***********@mic rosoft.com...
Can someone please tell me how I edit this code so it works with an
OleDB...

Thanks

Sub Application_Aut henticateReques t(ByVal sender As Object, ByVal e As
EventArgs)
' Fires upon attempting to authenticate the use
If Request.IsAuthe nticated Then
'Determine this user's roles
Dim reader As OleDbDataReader
reader =
SqlHelper.Execu teReader(Config urationSettings .AppSettings("s trConn"),
CommandType.Sto redProcedure, "rolesForUs er", New
OleDbParameter( "@Username" ,
User.Identity.N ame))

' Create an array of role names
Dim roleList As New ArrayList
Do While reader.Read()
roleList.Add(re ader("Name"))
Loop
reader.Close()

'Convert the roleList ArrayList to a String array
Dim roleListArray As String() =
roleList.ToArra y(GetType(Strin g))

'Add the roles to the User Principal
HttpContext.Cur rent.User = _
New
System.Security .Principal.Gene ricPrincipal(Us er.Identity, roleListArray)
End If
End Sub


Jun 12 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
4959
by: Javier Gomez | last post by:
Is it posible to change by code (in a form) the active .mdw by another one ? When I open the DB I have the system.mdw active after some procesess I need to change to another secure.mdw and make active, but I bought like it to make it by code inside of a form in button command click. (I do not want to make it thought tools bars menu.) Can anybody help ?
4
1835
by: William | last post by:
After much frustration I was able to update my data store via code only. Using the data adapter was the only way I was able to set up all the objects written in my code. Basically, I cheated by creating an adapter and then copy, paste, modify it's code to suite my needs. This was the end result: Private sub updateTable( ) Dim myData As DataSet 'Command is a form level oledbcommand object Dim Adapter1 As New OleDbDataAdapter(Command)
4
3360
by: Rob Kroese | last post by:
I've got a form with a datagrid that displays a list of items, along with several textboxes, comboboxes, etc., that display the details for the selected item. The columns in the datagrid and the "details" controls are both bound to fields in a dataview called dvItems. The dataview is a subset of a datatable called dtItems, which is simply a copy of all the data in a table called Items. The idea is to allow the user to edit an item in...
2
8658
by: Tim Frawley | last post by:
I am attempting to change the ODBC Link Provider String in an Access database linked to an Oracle server using ADOX in VB.NET. I created some code using the example from post: http://groups.google.com/groups?q=RefreshLinkedTablesWithADOX()&hl=en&lr=&selm=qb1ctvcdoftenojhpp34lb6fjb9ss8qd9c%404ax.com&rnum=1 My code simply replaces the DSN, UID, PWD and DBQ values in the ADOXTable.Properties("Jet OLEDB:Link Provider String").Value string...
0
1413
by: tconlon | last post by:
Hi folks. I'm trying to change the location of the Access mdb file I connect to using OleDb and am having trouble. I'm using Visual C# 2005 and the default values I use for the ConnectionString are those generated by the Server Explorer. I can connect just fine using the default values. But when I comment out strDefaultConnectionFile and uncomment the dbName variable I get: 'OleDbException: Could not use "; file already in use.' ...
3
3317
by: Jim in Arizona | last post by:
I have a gridview that's being populated from an access db query. The problem I'm having is that the date/time fields in access that are populating the gridview are showing both date and time, when the field should only be showing one or the other (date or time). Even on the back end of the database where the column properties are, I have chosen the smallest date/time formats. When the aspx page runs, it shows the date and time (ie:in a...
0
883
by: shapper | last post by:
Hello, I need to get a value which might be on a SQL database or Access database. My problem is I need to know which is the database type or, even better, create a code which would work for both databases. Anyway, first of all I am getting my connection string from Web.Config:
8
16183
by: fniles | last post by:
Can I change the connection time out in VB.Net 2003 and MS Access (using OLEDbConnection) ? When I use Connect Timeout = 60 in the connectionstring, I get an error "Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done." Thanks. ConnectionOLE = New OleDb.OleDbConnection sPath = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sDBPath &
13
1633
by: slinky | last post by:
I'm working on a problem with a form with 6 textboxes and a submit button for adding data to an Access database.I changed a few things and got it down to 1 error!. I have a Sub Page_Load and a Sub btnAdd: (It still doesn't like the 'SourceVersion' in the Sub Page_Load). Also I viewed the .aspx in the browser and got an error which I posted complete at the bottom of this post). Thanks for any clues... I'm almost there!!
0
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10246
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10209
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10023
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6803
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5459
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5582
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4135
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3750
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.