Jump to content
Xtreme .Net Talk

martin_d_bell

Members
  • Posts

    17
  • Joined

  • Last visited

martin_d_bell's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Hi all, I urgently need to know how to access the security attributes of a windows file to find the Windows Network User which has a file open and causes the file to be locked from other users. If anyone can point me in the right direction or show me the code I need to use that would be excellent. Thanks Martin
  2. I keep receiving an error on my asp.net application which says: Server Error in '/' Application. -------------------------------------------------------------------------------- Line 1: Incorrect syntax near ')'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: Line 1: Incorrect syntax near ')'. I believe this may be because I am passing a session variable into my SQL statement to search records. Because the user has kept the browser open and inactive for longer than 20 mins (my session timeout) this resets the session variable and cause the application to crash because it has no variable to search for. SqlSelectCommand3.CommandText = _ "SELECT [Pri Key], ProNu, Supplier, ConfirmedDate, Confirmed " & _ "FROM POP_Parts " & _ "WHERE ProNu = '" & ProjectNo & "' AND Supplier = '" & Session("SupplierID") & "'" Any ideas on a solution would be appreciated. Thanks
  3. Query Thanks for the advice on using a query with an outer join. That works perfect and saves me having to program anything! Sometimes you can overcomplicate things and forget somebody else has programmed the tools to do the job. Thanks again
  4. Hi All, I am quite new to programming and have grasped most things except for Nested For Loops which just will not click!! I am trying to write a small application which loops through two datasets and compares values in dataset1 to the values in dataset2. So far my code looks like this lblCheckDone.Visible = False lvbPartCodes.Items.Clear() If IsDBNull(DsPOPPartCodes1.POP_Parts_Costs) = False Then DsPOPPartCodes1.POP_Parts_Costs.Clear() SqlDAPOPPartCodes.Fill(DsPOPPartCodes1.POP_Parts_Costs) If IsDBNull(DsWDPartCodes1.POP_WDPcodes) = False Then DsWDPartCodes1.POP_WDPcodes.Clear() SqlDAWDPartCodes.Fill(DsWDPartCodes1.POP_WDPcodes) Dim x As Int16 Dim y As Int16 Dim PCode As String Dim PCodeDesc As String Dim Counter As String x = 0 y = 0 Counter = 0 For y = 0 To DsWDPartCodes1.POP_WDPcodes.Rows.Count - 1 PCode = DsWDPartCodes1.POP_WDPcodes.Rows(y).Item(1) PCodeDesc = DsWDPartCodes1.POP_WDPcodes.Rows(y).Item(2).ToString For x = 0 To DsPOPPartCodes1.POP_Parts_Costs.Rows.Count - 1 If " " + Replace(PCodeDesc, ",", "") <> DsPOPPartCodes1.POP_Parts_Costs.Rows(x).Item(2).ToString Then Dim lvbPartRow As New ListViewItem(PCode) lvbPartRow.SubItems.Add(PCodeDesc) lvbPartCodes.Items.Add(lvbPartRow) Counter = Counter + 1 lblCheckDone.Text = Counter Exit For End If Next Next SqlDAWDPartCodes.Update(DsWDPartCodes1.POP_WDPcodes) lblCheckDone.Visible = True I have a listview and a button on my form, when the user clicks the button the values which do not match need to be displayed in the listview. I just need help with the Nested For Loop as at the minute it lists all of the values in the ListView whether they match up or not. Thanks Martin
  5. Hi I have a line of code in my VB ASP.NET app which confirms a delete action on a datagrid. This works without problems but I need to make the Javascript alert multiline, I am struggling with the syntax and cannot figure out how to go about this. Example of what I need is ------------------------------------------ | | Are you sure you want to delete: | | Project No: 51151 | Date: 23/04/2005 | Notes: Sorry cannot confirm. | | OK CANCEL |_____________________________________ The code below is what works for a single line alert box. btnConfirm.Attributes("onClick") = "return confirm('Are you sure you wish to confirm:');" Any ideas how and where to place the "vblf" statement. Martin
  6. Login My login works using Forms Authentication in the Web.Config and checks for users in a SQL Server table. Is this the type of solution you need? If so the code is below: -------Web.Config------------------ <authentication mode="Forms" > <forms name="AuthCookie" path="/" loginUrl="logon.aspx" protection="All" timeout="30"></forms> </authentication> <authorization> <allow users="*" /> </authorization> ------------------------------------- replace "logon.aspx" to the page you want users directed to if they are not logged in ------------logon.aspx-------------------- Public Sub cmdLogin_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles cmdLogin.Click ' Tests There is A User name Dim cIn As Integer = 0 If txtUser.Text <> "" Then SqlDAConfirmUsers.SelectCommand.CommandText = _ "SELECT userID, UserName, Password, SupplierID, AccessLevel FROM Users_Table" & _ " WHERE (UserName = '" & txtUser.Text & "' )" & _ " ORDER BY UserName" 'Fills the Dataset SqlDAConfirmUsers.Fill(DsConfirmUsers1.POP_Confirmation_Users) 'Check that the users name is in the dataset If DsConfirmUsers1.POP_Confirmation_Users.Rows.Count < 1 Then Label1.Text = "Your Username was not recognised" Exit Sub End If 'Check that the username is not in the dataset more than once If DsConfirmUsers1.POP_Confirmation_Users.Rows.Count > 1 Then Label1.Text = "Username is duplicated, please contact the Administrator" Exit Sub End If 'Loops and Checks if the password is correctID Dim cTable = DsConfirmUsers1.POP_Confirmation_Users Dim cRow = DsConfirmUsers1.POP_Confirmation_Users.Rows For Each cRow In cTable If cRow("Password").ToString = Me.txtPassword.Text Then cIn = 1 'These session variables carry the UserID, AccessLevel and SupplierID through to any page within the application Session("UserID") = cRow(0).ToString Session("AccessLevel") = cRow(4) Session("SupplierID") = cRow(3).ToString 'This line lets the user into the system once all usernames and passwords are verified in the database FormsAuthentication.RedirectFromLoginPage(txtUser.Text, False) End If Next 'Incorrect password If cIn = 0 Then Label1.Text = "Your Password is Incorrect" DsConfirmUsers1.Clear() End If 'Incorrect username Else Label1.Text = "Your Username was incorrect" End If End Sub
  7. More than one account The users will be given seperate usernames but they are all going to be 1 digit off each other, for example, pro1, pro2, pro3. I cannot use real names as users because the users will change from time to time. I guess the only way around this is to hope that nobody logs in under the wrong name whilst someone else is logged in. The error message is messy you see and if I could stop them logging on in the first place it would be much tidier.
  8. Cookies or database table Hi, Thanks for your suggestion but how can I track that a user has logged out of the application if they simply close the browser. I may be wrong in thinking this but isn't the sub which is triggered on exit unreliable? I need a solid method of knowing when a user logs out.
  9. Hi, I have successfully setup forms authentication using a SQL Server database to store Usernames, Passwords and Session variables to pass user information between pages within my ASP.NET vb application. I have come across a problem however when more than 1 person logs in using the same username and password. How can I check if a user is logged in already in another session within the application? If I can check whether a username is already in use (logged in) then I can stop the second person logging in using the same name and therefore eliminate the problem. Any help would be appreciated, thank you. Martin
  10. Thanks Thanks alot for your help. I used the spit function in the end. Sometimes the answer is right under your nose but I manage to spend 2 hours over complicating things!! Oh well, thank you. ;)
  11. Hi Everyone, I have a string in the form of Blah1, Blah2, Blah3, Blah4, Blah5 I need to strip the Blah's and store them as separate string variables such as strVar1 = Blah1 strVar2 = Blah2 strVar3 = Blah3 etc etc The string will be of different lengths and could contain 3 Blah's or 8 Blahs so the string length is never constant. I get the feeling that a regular expression is the solution but haven't got a clue how to write one of these to do the job. If anyone could help it would be very much appreciated. Thanks in advance. Martin
  12. Hi, I am struggling at the minute trying to run my ASP.NET app on the host server. I am a little confused about where to put files and folders and which ones to upload!! (It was so easy in old fashioned ASP!!) I have one virtual directory on the host server. The root of the host contains a standard HTML website which can be reached by "www.mysite.co.uk" and I need to create a directory in the root called Supplier which will be accessed via "www.mysite.co.uk/supplier". The supplier folder is the folder where the ASP.NET app needs to be. I am having great difficulty and any changes I make to the web.config file such as showing remote users detailed error messages are being ignored by the server. Any ideas? Also, should my host be giving me any tools to administer the IIS settings or do I have to simply rely on them to make all the changes on my behalf?
  13. The line of code that says System.IO.File.OpenWrite(strFileName) makes no difference. I have deleted it and it still gives the same error.
  14. Hi all, I am really struggling with this one!! I need to let users delete a bitmap file from a location on a server and also delete a record relating to this bitmap from a database at the same time. Every time I click on the delete button it throws an exception message saying "The process cannot access the file "\\server\blah\blah\myfile.bmp" because it is being used by another process" I think I need to close the process somehow but have no clue how to do this. My code is shown below: Try If MessageBox.Show("Are you sure you want to Delete this document?" & vbLf & vbLf & "NOTE: If you click Yes you will not be able to retrieve this Document.", "Delete Document", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then strFileID = DsVerifyDoc1.tblListerDoc.Rows(0).Item(0) If docVerified = 1 Then If System.IO.File.Exists(strFileName) = True Then Try ILFrames.Dispose() LVBResults.Items.Clear() System.IO.File.OpenWrite(strFileName) System.IO.File.Delete(strFileName) Catch ex As Exception MsgBox(ex.Message) Exit Sub End Try Else Me.lblVerified.Text = "Sorry but the Document you are trying to delete does not exist" End If SqlDeleteCommand1.CommandText = "DELETE FROM tblListerDoc WHERE (ID = '" & strFileID & "')" SqlDeleteCommand1.Connection = SqlCDocSearch DsVerifyDoc1.tblListerDoc.Rows(0).Delete() SqlDAVerifyDoc.Update(DsVerifyDoc1.tblListerDoc) DsVerifyDoc1.tblListerDoc.Clear() Else End If LVBResults.Items.Clear() End If Catch ex As Exception MsgBox("SQL ERROR: Please try again") End Try Any help would be appreciated as I am tearing my hair out over this one. Martin
  15. Figured it out.... I have figured this problem out now with thanks to the MSDN web site. If anybody comes across this and needs the answer I got it here http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbtskaddingbuttoncolumnstodatagridwebcontrol.asp
×
×
  • Create New...