|
During an Update call on the DataAdapter?? This cannot be done. You'd have to supply code to examine each record in the DataSet/DataTable you're Updating and commit the changes to the database yourself, supplying the extra code to create or delete new tables during the process.
Access does respond to the usual SQL commands CREATE TABLE[^]and DROP TABLE[^]. You'd also have to include the field definitions in the CREATE TABLE statement. Executing the SQL command would just involve creating and properly setting up both an OleDbConnection and OleDbCommand object, opening the connection, calling ExecuteNonQuery on the command object, then closing the connection.
|
|
|
|
|
hi all
i have to validate a textbox according to datetime of MM/DD/YYYY
i an new to here(windwos application)please help me how to do
bye byes
prashanth,
s/w Engineer,
Syfnosys.
|
|
|
|
|
Try checking out DateTime.ParseExact[^] method. It will throw an exception if the string doesn't match the format specifier exactly. IF it does return a good date, all you have to do after that is make sure it's within a valid range for your requirements.
|
|
|
|
|
I am developing a VB.NET text based adventure and I need help with coding a log in button.
Basically I have a table called tblUserAccounts
This table as 3 fields...
accountID
username
Password
The log in screen form has a combo box for username and a text box for password with a button just to the right that says Log in.
What I want to happen is that when the person clicks log in after they enter there information into the combo box and text box, that (insert code here) will basically take their username and password(that they entered) and search for it in the database and if it exists in the database allow them to log in.
OR
Alternatively I could make array variables that are = to the table columns(from the database) username and password, then I can perform my own checks in the VB.Net code itself on the button click.
for example I tried doing this...
Dim arrUsername() As Array = GameprojectDatabase.tblUserAccounts.UserColumn
but I get the message that it can not be converted to a 1-dimensional array
If anyone can explain to me how I can do this please let me know.
|
|
|
|
|
This would be easy enough with an SQL query to your Access database:
SELECT COUNT(Username) FROM Users WHERE Username=?Username And Password=?Password
This is, of course, ignoring all security concerns and assumes that all the passwords are stored unencrypted.
All you would have to do is create an OleDbConnection to the database, an OleDbCommand object to execute the query, a couple of OleDbParameter objects, added to the Parameters collection of the OleDbCommand object, with the username and password values filled in, and then call the ExecuteScalar method of the command object. The number returned by that call will tell you how many username/password records matched the inputs. It SHOULD be 1 or 0. If 0, then the login failed. If 1, it worked. If MORE than 1, you've got a consistancy problem with your data as there are more than 1 record in the table with the same username and password.
|
|
|
|
|
Thank you ...Now if I only knew how to do that lol.
I read stuff like this elsewhere but have not found anywhere that explains it clearly. Looking through help files is like trying to find a needle in a haystack, and not only that the needle your looking for has hundreds of twins that confuse the heck out of you.
|
|
|
|
|
I'm sure you've seen something like this:
Public Function AttemptLogin(ByVal Username As String, ByVal Password As String) As Boolean
Dim queryString As String = "SELECT COUNT(Username) FROM User WHERE Username=?Username AND Password=?Password"
Dim result As Integer = 0
Using connection As New OleDbConnection(connectionString)
Dim command As New OleDbCommand(queryString, connection)
command.Parameters.Add(New OleDbParameters("?Username", OleDbType.VarChar, 15)).Value = "someusername"
command.Parameters.Add(New OleDbParameters("?Password", OleDbType.VarChar, 15)).Value = "somepassword"
connection.Open()
result = command.ExecuteScalar()
connection.Close()
Return (result=1)
End Using
End Function
|
|
|
|
|
Hello. That must be quite simple. I have a text file and I want to replace spaces with returns. I'm trying that code, but it doesn't work:
Dim i As Integer = 1
While Not myreader.EndOfStream
line = myreader.ReadLine()
line = i & line.Replace(" "c, vbCrLf)
mywriter.WriteLine(line)
i += 1
End While
myreader is a StreamReader and mywriter is a StreamWriter. Line is a String.
Do you see the problem here?
Regards,
Diego F.
|
|
|
|
|
Standard Question #1: What does "it doesn't work" mean?
What happens? Do you get an error message? What does the expected output look like? What does the actual output look like?
Are both streams created on the same file? You can NOT do that. You can not replace a line in a text file. You have to write an entirely new text file with the modified data.
|
|
|
|
|
I'm sorry for the loose explanation.
myreader references the original file and mywriter a new file
The original file contains large lines with some spaces.
I want to insert line breaks to see the file with more ease.
With the code above, the resulting file is just as the original file. No line breaks are inserted.
Regards,
Diego F.
|
|
|
|
|
OK. Are you sure that the whitespace characters in the original file are spaces and not some other non-visibile character, like Tab?
The code, as you have it, should work, but only for single spaces. You'd be better off using a Regular Expression that can replace all kinds of whitespace characters without you knowing what they are ahead of time:
Imports System.Text.RegularExpressions
.
.
.
' Define a RegEx expression that matches strings
' of 1 or more whitespace characters.
Dim re As New Regex("\s+")
Dim i As Integer = 1
While Not myreader.EndOfStream
line = myreader.ReadLine()
line = i & re.Replace(line, vbCrLf)
mywriter.WriteLine(line)
i += 1
End While
|
|
|
|
|
Thank you for your help.
Regards,
Diego F.
|
|
|
|
|
I replaced " "c for Chr(0) and now it works.
Regards,
Diego F.
|
|
|
|
|
This would answer the question in my previous reply. Those spaces are NOT spaces. The space character you specified is ASCII character 32. The character you supplied in this post is ASCII character 0.
|
|
|
|
|
Hey all,
I wrote a simple web form that has a drop down list with various property locations. I need my code to assign a specific email address to a selectedindex value based on the location.
For instance:
If the user selects Detroit as the location, then the recipient of the mailmessage should be detroit@company.com.
Can I do this correctly in an If/Then statement outside of my MailMessage sub? Like :
<br />
Dim Address As System.Net.Mail.MailAddress<br />
If ddlLocation.SelectedIndex = 1 Then<br />
Address = "helpdesk@turnberry.com"<br />
End If<br />
Obviously I need to convert the string somehow, so any help here would be great.
Thanks!!
|
|
|
|
|
You could do it that way, or you could just get the data from the SelectedItem in the ComboBox, or from the SelectedValue property if you're using a bound ComboBox, or looking up in a table you have. This really depends on how you filled the ComboBox and from what kind of source and the format of the email address.
If it were me, and I'm making a couple of large assumptions here, I'd probably have the Location and email address in a table, bind the combobox to it setting the Location column as the DisplayMember and the email address as the ValueMember, then do something like:
Dim emailAddr As String = ComboBox.SelectedValue
Or
Dim emailAddr As String = ComboBox.SelectedValue @ "@someplace.com"
The second way is less flexible though.
|
|
|
|
|
As you mentioned using the value, I realized how complicated I was making this. Thanks for your direction.
I just added a single line of code in my submit click event and added the emails to the ddl as values and everything works great!
<br />
Dim Email As New System.Net.Mail.MailMessage( _<br />
"email@email.com", ddlLocation.SelectedValue)<br />
Thanks again!
|
|
|
|
|
Good afternoon Sir,
I need your help please to tell me how I can send and receive numerical data (not string data) from client to server and vice versa.
Note:
Using visual basic6 or VB.Net code if possible.
Where input values (N1, N2, N3) are numbers in client side not string and outputs (return values Max & Average)in server side.
Thank you so much
Akwanin.M
m.Ekwanin
|
|
|
|
|
Marwan Ekwanin wrote: I need your help please to tell me how I can send and receive numerical data (not string data) from client to server and vice versa.
You can't.
You have to convert the numeric values into strings before you send them, and convert them from strings when you have recieved them.
---
single minded; short sighted; long gone;
|
|
|
|
|
Hi Friends.....
I have 4 project in one solution.I want to imports my project in the main project.
I try to import my project by the following code.
imports Company.ProName.Mysol
In here Mysol is my project name.
But i can't get Mysol after the ProName.
What is the reason? Tell me the clear idea.
Urgent Friends.......Plz Help Me............
|
|
|
|
|
You need to add a reference to the actual dll.
Hope that helps.
Ben
|
|
|
|
|
Wrong.
You add the reference to the Project - not the .dll. This will save you all kinds of headaches later on if you make changes to the referenced project.
|
|
|
|
|
You are right. I guess I missed the part of the Projects all being in the same solution. It does save a lot of headaches.
Ben
|
|
|
|
|
Add a reference to the project you want to import from, not the .DLL file.
|
|
|
|
|
I have 2 forms in my project.
Form1 has a Panel1 with 25 buttons in the Panel1.
Form2 has a Panel2 which is empty Panel2.
Now my qustion is:
Every time I click on any of these buttons (25 buttons within the Panel1) I want these buttons to be displayed within the Panel2.
E.g. If i click button1 i want this button1 to be displayed within the panel2 of form2.
Im new in VB .NET
If anyone can halp me on this it would be very greatful...
Kind Regards
Roni
-- modified at 11:19 Thursday 31st May, 2007
|
|
|
|