|
|
This is a very specific application. One where there isn't going to be a whole lot of experience floating around. Your single best source of information would be the support forums on the company that made the device.
|
|
|
|
|
hey all, i have a list box displaying data, with all the formatting anf all of that
Dim fmtStr As String = "{0, -15} {1, -7}"
lstDisplay.Items.Add(String.Format(fmtStr, inputNum, inputNum * inputNum2))
so far everything works fine
Now, I need to search in the listbox ....
im, making use of the indexOF function
this function listBox.items.indexof("fgfgfg") works fine when the listbox is not formatted, when it is formatted ... i do not get any error messages ... it shows that the thing im searching for isnt there when it really is there .. any ideas?
gHoSt
|
|
|
|
|
Hi,
AFAIK ListBox.Items.IndexOf() will only match exact strings, i.e. it will not find partial
matches. You should look at ListBox.FindString() instead, which does partial matching.
Check the documentation on these methods!
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
When Opening the other windows form old windows form should be closed otherwise i want a code to display eror massage that please close the old form .
i want latest and professional code .
please send me yar.
Pavan
|
|
|
|
|
Noone is going to write the code for you. There is no "latest" code to do this. YOU have to write the code.
It's not that difficult. All you do is maintain a variable that holds the currently opened Form object. If, when creating a new form, you check that variable and see that it's not Nothing, you can put up your warning. If it's Nothing, then it's safe to create your new form and put it in that variable. When that form closes, you set the variable to Nothing.
|
|
|
|
|
Hi to all!
I am new of The Code Project....
I'm trying to develop an application for my PDA Device ( Windows Mobile 2003 SE), using Visual Studio 2005 and .NET Compact Framework in Basic language.
It consist in drawing a diagram, reading data from a Text file.
I already reached a decent result, but now I am a little in difficulties, because in this text file there is a field containing a Date/Time value in TDateTime format (Delphi/Pascal or C++ language?), that I must read and convert in Basic format (or in string).
I not found any simple resolution (for me) to solve this problem, also because I don't know other programming languages.
Someone can help me, please?
Thanks in advance.
Marco
|
|
|
|
|
Since I've never used Delphi, I don't know what the Date/Time looks like in a text file.
From what I can Google, it look like a Delphi DateTime is stored as a Double type in VB.NET. After getting that, it should be a matter of some simple math to convert it to a DateTime type.
|
|
|
|
|
Thanks for help Dave.
Following is a sample of the text file that I need to get data:
Example
-27.350436, 153.055540,1,-777,36169.6307194, 09-Jan-99, 3:08:14
-27.348610, 153.055867,0,-777,36169.6307194, 09-Jan-99, 3:08:14
Field 1 : Latitude - decimal degrees.
Field 2 : Longitude - decimal degrees.
Field 3 : Code - 0 if normal, 1 if break in track line
Field 4 : Altitude in feet (-777 if not valid)
Field 5 : Date - see Date Format below, if blank a preset date will be used
Field 6 : Date as a string
Field 7 : Time as a string
Date Format
Delphi stores date and time values in the TDateTime type. The integral part of a TDateTime value is the number of days that have passed since 12/30/1899. The fractional part of a TDateTime value is the time of day.
Following are some examples of TDateTime values and their corresponding dates and times:
0 --------> 12/30/1899 12:00 am
2.75 -----> 1/1/1900 6:00 pm
-1.25 ----> 12/29/1899 6:00 am
35065 ----> 1/1/1996 12:00 am
The problem for me is that not ever Date and Time (in string format) are present in the text file, but only the TDateTime format.
I hope that with above sample is more easy to understand my problem.
Marco
|
|
|
|
|
The error is highighter at While sqlReader.Read()
Is there a syntax error?
please help.
Dim conMbr As New SqlConnection
Dim cmdMbr As New SqlCommand
Dim sqlReader As New SqlDataReader
Dim strVerifyMbr as String
conMbr = New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename='C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\GpsCinema.mdf';Initial Catalog=GpsCinema;Persist Security Info=True;User ID=sa;Password=password;MultipleActiveResultSets=True;Connect Timeout=30;User Instance=False;Context Connection=False")
conMbr.Open()
strVerifyMbr = "SELECT MemberId FROM datMember WHERE memberUserName=@usrId AND memberPassword=@pwd"
cmdMbr = New SqlCommand(strVerifyMbr,conMbr)
Dim checkUsr as string =""
While sqlReader.Read()
If txtLogin.Text=Convert.ToString(sqlReader("memberUsername"))Then
If txtPwd.Text=Convert.ToString(sqlReader("memberPassword")) Then
Session("username") = sqlReader("memberUsername")
Session("password") = sqlReader("memberPassword")
Server.Transfer("Main.aspx")
Else
Response.Write("window.alert('Invalid Password. Please try again.');<" + "/script>")
Server.Transfer("Main.aspx")
End If
End If
checkUsr="Failed"
End While
If checkUsr ="Failed" Then
Response.Write("<SCRIPT lanquage='JScript'>window.alert('Invalid Username! Please Try Again.');<" + "/SCRIPT>")
Server.Transfer("staffLogin.aspx")
End If
<div class="ForumSig">Life is up and down
Nevertheless,never give up hope and be confident to yourself</div>
|
|
|
|
|
Standard question #1: What's the exception message??
|
|
|
|
|
OP has nice subject line. What the frick is an instructor in the context of a programming language? I know the OP probably meant constructor
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
I don't have any idea either. Now that the "questions" have gotten so bad over the last couple of years, I guess it was only inevitable that the "English" used to ask them followed.
|
|
|
|
|
Dave Kreskowiak wrote: I guess it was only inevitable that the "English" used to ask them followed.
Seems like it
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
A couple of points:
1. Your code is virtually unreadable. Putting <pre> tags around it would improve things.
2. Using Response.Write to render JavaScript code is bad practice. ASP.NET has the Page.ClientScriptManager class to assist with including script in your page output.
I don't know what is causing your problem because you haven't provided details of the error message.
Paul Marfleet
|
|
|
|
|
What a mess...
kc_renji wrote: System.Data.SqlClient.SqlDataReader has no instructor?
Read the error message again. That's not what it says.
Is there a syntax error?
No.
Dim conMbr As New SqlConnection
Don't create a connection object when you declare the reference. As you create another connection object when you open the connection, this first connection object is only created and then thrown away.
Dim cmdMbr As New SqlCommand
Don't create a command object when you declare the reference. As you create another command object when you specify the query, this first command object is only created and then thrown away.
Dim sqlReader As New SqlDataReader
You can't create a data reader using the new keyword, as there is no public constructor that can be used for that.
You shouldn't try to create a data reader object when you declare the reference. As you will be creating one when you execute the query, the first object would only be created and then thrown away.
strVerifyMbr = "SELECT MemberId FROM datMember WHERE memberUserName=@usrId AND memberPassword=@pwd"
If you have parameters in your query, you have to add parameter objects to the command object to provide their values.
While sqlReader.Read()
You have to create the data reader before you can read from it. Call the ExecuteReader method of the command object to execute the query and get the result in a data reader.
If txtLogin.Text=Convert.ToString(sqlReader("memberUsername"))Then
The data reader doesn't contain any field named "memberUsername", as you don't get any data from that field in the query.
If txtPwd.Text=Convert.ToString(sqlReader("memberPassword")) Then
The data reader doesn't contain any field named "memberPassword", as you don't get any data from that field in the query.
Session("password") = sqlReader("memberPassword")
Why are you storing the password in the session variables? Are you going to check the password against the database every time you want to check if the user is logged in?
Else
This will never happen. As you only get the user record from the database if the password is correct, you will never have any record in the data reader where the user name is correct and the password is wrong.
Response.Write("window.alert('Invalid Password. Please try again.');<" + "/script>")</blockquote>
Don't use JScript, that is only supported by Internet Explorer. Use Javascript.
Using Response.Write is not a good way of putting code in the page. It will place the code above the doctype, which will make the browser ignore the doctype and render the page in quirks mode.
<blockquote class="FQ">checkUsr="Failed"</blockquote>
This code will never be reached. If the user name or password is not correct, the data reader will be empty, and you will never enter the loop.
<blockquote class="FQ">If checkUsr ="Failed" Then</blockquote>
As the variable will never have that value, the code in the if statement will never be executed.
<div class="ForumSig"><small><small>---
"Anything that is in the world when you're born is normal and ordinary and is just a natural part of the way the world works. Anything that's invented between when you're fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it. Anything invented after you're thirty-five is against the natural order of things."
-- Douglas Adams</small></small></div>
|
|
|
|
|
My Access database isn't being updated, but no errors occurred in my application
I have the following code in a class library:
Public Class clsSlaveBD
Dim strConString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\Karate.mdb;Persist Security Info=True"
Public drSlave As OleDbDataReader
Public Function getConexao() As OleDbConnection
Return New OleDbConnection(strConString)
End Function
Public Sub login(ByVal inNome As String, ByVal inPass As String, ByVal inTipo As String)
Dim comLogin As New OleDbCommand("SELECT Nome, Password, Tipo FROM Utilizadores Where (Nome=@Nome AND Password=@Pass AND Tipo=@Tipo)")
With comLogin
.Connection = getConexao()
.Connection.Open()
.Parameters.Add(New OleDbParameter("@Nome", inNome))
.Parameters.Add(New OleDbParameter("@Pass", inPass))
.Parameters.Add(New OleDbParameter("@Tipo", inTipo))
drSlave = .ExecuteReader
End With
End Sub
Public Sub altpass(ByVal inNome As String, ByVal inPass As String, ByVal inNovPass As String)
Dim comAltPass As New OleDbCommand("UPDATE [Utilizadores] SET [Password]=@NovPass WHERE [Nome]=@Nome AND [Password]=@Pass")
With comAltPass
.Connection = getConexao()
.Connection.Open()
.Parameters.Add(New OleDbParameter("@Nome", inNome))
.Parameters.Add(New OleDbParameter("@Pass", inPass))
.Parameters.Add(New OleDbParameter("@NovPass", inNovPass))
drSlave = .ExecuteReader
End With
End Sub
Protected Overrides Sub Finalize()
MyBase.Finalize()
End Sub
End Class
And in the event click of a button in a windows form the following code:
Public Class frmAltPass
Public strNovPass As String
Private Sub cmdValPass_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdValPass.Click
If txtPassAct.Text <> "" And txtNovPass.Text <> "" And txtConfPass.Text <> "" Then
If txtPassAct.Text = frmLogin.strPass And txtNovPass.Text = txtConfPass.Text Then
strNovPass = txtNovPass.Text
Dim clsSlaveBD As New BD_Slave.clsSlaveBD
clsSlaveBD.altpass(frmLogin.strUtil, frmLogin.strPass, strNovPass)
MsgBox("Password alterada com êxito", MsgBoxStyle.Information, "")
frmMDI.sbMsgAp.Text = ""
frmLogin.strPass = strNovPass
Me.Dispose()
Else
frmMDI.sbMsgAp.Text = "Erro na digitação das passwords. Reinsira a password."
Dim ctl As Control
For Each ctl In Me.Controls
If TypeOf ctl Is TextBox Then
ctl.Text = ""
End If
Next
End If
Else
MessageBox.Show("Todos os campos são de preenchimento obrigatório")
Dim ctl As Control
For Each ctl In Me.Controls
If TypeOf ctl Is TextBox And ctl.Text = "" Then
ctl.Select()
End If
Next
End If
End Sub
End Class
Both the variables frmLogin.strUtil and frmLogin.strPass are defined as Public in frmLogin form.
The application shows no errors but the database isn't updating the table "Utilizadores".
Can someone help me, please.
I have the following code in a class library:
Public Class clsSlaveBD
Dim strConString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\Karate.mdb;Persist Security Info=True"
Public drSlave As OleDbDataReader
Public Function getConexao() As OleDbConnection
Return New OleDbConnection(strConString)
End Function
Public Sub login(ByVal inNome As String, ByVal inPass As String, ByVal inTipo As String)
Dim comLogin As New OleDbCommand("SELECT Nome, Password, Tipo FROM Utilizadores Where (Nome=@Nome AND Password=@Pass AND Tipo=@Tipo)")
With comLogin
.Connection = getConexao()
.Connection.Open()
.Parameters.Add(New OleDbParameter("@Nome", inNome))
.Parameters.Add(New OleDbParameter("@Pass", inPass))
.Parameters.Add(New OleDbParameter("@Tipo", inTipo))
drSlave = .ExecuteReader
End With
End Sub
Public Sub altpass(ByVal inNome As String, ByVal inPass As String, ByVal inNovPass As String)
Dim comAltPass As New OleDbCommand("UPDATE [Utilizadores] SET [Password]=@NovPass WHERE [Nome]=@Nome AND [Password]=@Pass")
With comAltPass
.Connection = getConexao()
.Connection.Open()
.Parameters.Add(New OleDbParameter("@Nome", inNome))
.Parameters.Add(New OleDbParameter("@Pass", inPass))
.Parameters.Add(New OleDbParameter("@NovPass", inNovPass))
drSlave = .ExecuteReader
End With
End Sub
Protected Overrides Sub Finalize()
MyBase.Finalize()
End Sub
End Class
And in the event click of a button in a windows form the following code:
Public Class frmAltPass
Public strNovPass As String
Private Sub cmdValPass_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdValPass.Click
If txtPassAct.Text <> "" And txtNovPass.Text <> "" And txtConfPass.Text <> "" Then
If txtPassAct.Text = frmLogin.strPass And txtNovPass.Text = txtConfPass.Text Then
strNovPass = txtNovPass.Text
Dim clsSlaveBD As New BD_Slave.clsSlaveBD
clsSlaveBD.altpass(frmLogin.strUtil, frmLogin.strPass, strNovPass)
MsgBox("Password alterada com êxito", MsgBoxStyle.Information, "")
frmMDI.sbMsgAp.Text = ""
frmLogin.strPass = strNovPass
Me.Dispose()
Else
frmMDI.sbMsgAp.Text = "Erro na digitação das passwords. Reinsira a password."
Dim ctl As Control
For Each ctl In Me.Controls
If TypeOf ctl Is TextBox Then
ctl.Text = ""
End If
Next
End If
Else
MessageBox.Show("Todos os campos são de preenchimento obrigatório")
Dim ctl As Control
For Each ctl In Me.Controls
If TypeOf ctl Is TextBox And ctl.Text = "" Then
ctl.Select()
End If
Next
End If
End Sub
End Class
Both the variables frmLogin.strUtil and frmLogin.strPass are defined as Public Shared in frmLogin. The application shows no errors but the database isn't updating the table "Utilizadores".
Can someone help me, please.
|
|
|
|
|
I haven't read your post because, frankly, it's just way to freakin' long.
But, I take it that every time you run your application from inside the Visual Studio environment, the database looks like it's getting changed, but then you run it again and the changes are lost??
This is because the database .MDB file in your project is being copied to the Debug folder where your .EXE is being run from every time you run your code. Click on the file in the Solution Explorer and look at the Properties window. There's an option in there that says "Copy to Output Directory". Right now, it probably says "Copy Always". This is what's overwriting your changes in the database every time you run your app from inside Visual Studio.
|
|
|
|
|
Dave Kreskowiak wrote: I haven't read your post because, frankly, it's just way to freakin' long.
I scrolled through it and didn't bother looking at the code because it was too long (wanted to first see what I was up against)
"Find it your bloody self - immediately!" - Dave Kreskowiak
|
|
|
|
|
I apologize for extension of my previously post.
Answering your reply, let me tell you that before I submited my problem to this forum, I had allready verified that the propertie "Copy to Output Directory" of the .MDB file was set to "Do not Copy", so I don't think the problem is there.
Besides that, what do you think that could be the problem?
Let me thank you for your time sppending with this trivial to you, technical trouble.
David Manuel Pires
|
|
|
|
|
Verify the path to the database file actually being used in your code.
The most common cause of the problem is what I already described.
Beyond that, the problem is in your code, but with no code snippet doing the update and no exception messages (you're not just eating them in a Try/Catch block are you??) there's little that anyone can tell you.
One thing does come to mind. In your UPDATE SQL verify that you are supplying the correct UDPATE, INSERT, and DELETE statements that will work on just ONE record in the WHERE clause.
|
|
|
|
|
The path is correct, and the SQL instruction is also correct. I've tried it directly against the database and it update the table without a problem.
Also, I'm not bot using a Try/Catch block, and I'm not receiving any exceptions from the application.
What do you mean by "code snippet"?
Again, I thank you a lot.
David Manuel Pires
|
|
|
|
|
Post only the portion of code where you suspect the problem, and not the whole thing.
"Find it your bloody self - immediately!" - Dave Kreskowiak
|
|
|
|
|
Sorry for the extension of my previous post. The portion of the code is:
Public Class clsSlaveBD
Dim strConString As String = "Provider=Microsoft.Jet.OLEDB.4.0;DataSource=|DataDirectory|\Karate.mdbersist Security Info=True"
Public drSlave As OleDbDataReader
Public Function getConexao() As OleDbConnection
Return New OleDbConnection(strConString)
End Function
Public Sub altpass(ByVal inNome As String, ByVal inPass As String, ByVal inNovPass As String)
Dim comAltPass As New OleDbCommand("UPDATE [Utilizadores] SET [Password]=@NovPass WHERE [Nome]=@Nome AND [Password]=@Pass")
With comAltPass
.Connection = getConexao()
.Connection.Open()
.Parameters.Add(New OleDbParameter("@Nome", inNome))
.Parameters.Add(New OleDbParameter("@Pass", inPass))
.Parameters.Add(New OleDbParameter("@NovPass", inNovPass))
drSlave = .ExecuteReader
End With
End Sub
Protected Overrides Sub Finalize()
MyBase.Finalize()
End Sub
End Class
Public Class frmAltPass
Public strNovPass As String
Private Sub cmdValPass_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdValPass.Click
If txtPassAct.Text <> "" And txtNovPass.Text <> "" And txtConfPass.Text <> "" Then
If txtPassAct.Text = frmLogin.strPass And txtNovPass.Text = txtConfPass.Text Then
strNovPass = txtNovPass.Text
Dim clsSlaveBD As New BD_Slave.clsSlaveBD
clsSlaveBD.altpass(frmLogin.strUtil, frmLogin.strPass, strNovPass)
end sub
Can you help me?
David Manuel Pires
end class
|
|
|
|
|
I don't mean to nit-pick, but plaintext passwords are a really bad idea.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|