|
It can be created just like any other table in Access. Open the .MDB file your using by double-clicking on it. In Access, click on the "Tables" label, then click design. Add your username and password fields...
...hmmm...Have you used Access before? Any previous programming experience?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Yes, I do have Access programming experience and I also use the design view and the primary key.
bravo659
|
|
|
|
|
Then you have everything you need to create the table using Access.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks for your reply to my inquiries. It is helpful. All I ahve to do is shift the coding around until I get the correct code.
Thanks Again!
|
|
|
|
|
Hi,
I have populated my datagrid from a dataset.
I want to set values for the second col wherein the user can enter only 'AGE' or 'DOB' in the second col. i.e. If user hits 'A' on the key board I want to display 'AGE' in the second col or if the user hits 'D' to display "DOB" in the second col. But if the users enters any other value other than 'A' or 'D' then I want to cautio user with a msgbox.
Is this possible with the new datagrid?
Tnx
|
|
|
|
|
|
Validating Input with the Windows Forms DataGrid Control
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbtskHandlingErrorsWithWindowsFormsDataGridControl.asp?frame=true
|
|
|
|
|
I tried this code but having a tiny problem:
I get the error @ AddHandler customersDataSet1.Tables("Customers").ColumnChanging, AddressOf Customers_ColumnChanging
any idea?
Imports System.Data
Imports System.Data.OleDb
Inherits System.Windows.Forms.Form
Dim da As New OleDbDataAdapter()
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim ds As New Data.DataSet()
' Visual Basic
' Assumes the grid is bound to a dataset called customersDataSet1
' with a table called Customers.
' Put this code in the form's Load event or its constructor.
Dim conn As OleDbConnection = New OleDbConnection("Provider = Microsoft.jet.oledb.4.0;Data source = D:\Program files\Microsoft Visual Studio .NET\Crystal Reports\Samples\Database\Xtreme.mdb")
If conn.State <> ConnectionState.Open Then conn.Open()
da.SelectCommand.CommandText = "Select * from customer"
da.SelectCommand.CommandType = CommandType.Text
da.Fill(ds, "customersDataSet1")
DataGrid1.DataSource = ds
DataGrid1.DataMember = "customersDataSet1"
AddHandler customersDataSet1.Tables("Customers").ColumnChanging, AddressOf Customers_ColumnChanging
End Sub
Private Sub Customers_ColumnChanging(ByVal sender As Object, _
ByVal e As System.Data.DataColumnChangeEventArgs)
' Only check for errors in the Product column
If (e.Column.ColumnName.Equals("Product")) Then
' Do not allow "Automobile" as a product.
If CType(e.ProposedValue, String) = "Automobile" Then
Dim badValue As Object = e.ProposedValue
e.ProposedValue = "Bad Data"
e.Row.RowError = "The Product column contians an error"
e.Row.SetColumnError(e.Column, "Product cannot be " & _
CType(badValue, String))
End If
End If
End Sub
|
|
|
|
|
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim ds As DataSet = New DataSet
Dim strSQL As String
Dim cmSQL As OleDbCommand
Dim conn As OleDbConnection = New OleDbConnection( _
"Provider = Microsoft.jet.oledb.4.0;Data source = C:\Program files\Microsoft Visual Studio .NET\Crystal Reports\Samples\Database\Xtreme.mdb")
If conn.State <> ConnectionState.Open Then conn.Open()
strSQL = "SELECT * FROM Customer"
cmSQL = New OleDbCommand(strSQL, conn)
da.SelectCommand = cmSQL
da.Fill(ds, "Customer")
DataGrid1.DataSource = ds.Tables(0)
AddHandler ds.Tables(0).ColumnChanging, AddressOf Customers_ColumnChanging
End Sub
|
|
|
|
|
I forgot to change your drive letter back to D: in the last post, sorry.
Here is the rest of the code.
Private Sub Customers_ColumnChanging(ByVal sender As Object, _
ByVal e As System.Data.DataColumnChangeEventArgs)
' Only check for errors in the Contact Title column
If (e.Column.ColumnName.Equals("Contact Title")) Then
' Do not allow it to be empty
If CType(e.ProposedValue, String) = String.Empty Then
Dim badValue As Object = e.ProposedValue
e.ProposedValue = "Bad Data"
e.Row.RowError = "The Contact Title column contians an error"
e.Row.SetColumnError(e.Column, "Contact Title cannot be Empty")
Else
e.Row.ClearErrors()
End If
End If
End Sub
|
|
|
|
|
Thanks a bunch.
Its working fine.
|
|
|
|
|
There is one tiny problem here.
I want to check if the value entered is 'Mr' or 'Mrs'
ElseIf CType(e.ProposedValue, String) <> "Mr" or CType(e.ProposedValue, String) <> "Mrs" Then
But when I enter Mr or Mrs it displays the error mssg.
But when I check the value individually it works fine:
ElseIf CType(e.ProposedValue, String) <> "Mr" Then
If (e.Column.ColumnName.Equals("Contact Title")) Then
' Do not allow it to be empty
If CType(e.ProposedValue, String) = String.Empty Then
Dim badValue As Object = e.ProposedValue
e.ProposedValue = "Bad Data"
e.Row.RowError = "The Contact Title column contians an error"
e.Row.SetColumnError(e.Column, "Contact Title cannot be Empty")
' Do not allow if the value is not 'Mr' or Mrs
ElseIf CType(e.ProposedValue, String) <> "Mr" Or CType(e.ProposedValue, String) <> "Mrs" Then
Dim badValue As Object = e.ProposedValue
e.ProposedValue = "This field is limited to'Mr','Mrs'"
e.Row.RowError = "The Contact Title column contians an error"
e.Row.SetColumnError(e.Column, "Contact Title cannot be Empty")
Else
e.Row.ClearErrors()
End If
End If
|
|
|
|
|
Yes, that is a strange problem, but I it works good this way.
Private Sub Customers_ColumnChanging(ByVal sender As Object, _
ByVal e As System.Data.DataColumnChangeEventArgs)
' Only check for errors in the Contact Title column
If (e.Column.ColumnName.Equals("Contact Title")) Then
Select Case CType(e.ProposedValue, String)
Case String.Empty
Dim badValue As Object = e.ProposedValue
e.ProposedValue = "Bad Data"
e.Row.RowError = "The Contact Title column contians an error"
e.Row.SetColumnError(e.Column, "Contact Title cannot be Empty")
Case "Mr."
e.Row.ClearErrors()
Case "Mrs."
e.Row.ClearErrors()
Case "Miss"
e.Row.ClearErrors()
Case "Dr."
e.Row.ClearErrors()
Case Else
Dim badValue As Object = e.ProposedValue
e.ProposedValue = "Bad Data"
e.Row.RowError = "This field is limited to'Mr','Mrs'"
e.Row.SetColumnError(e.Column, "Contact Title cannot be Empty")
End Select
End If
End Sub
|
|
|
|
|
|
Yes, that is very strang it can't seem to evaluate "And" "Or" either. humm, guess it's a glitch.
I don't know if you noticed it or not but if you hover over the red Icon's when it's in error it produces a popup balloon to tell you the error.
It will not set "Changes" to the dataset either, until all the errors are cleared. You can trap that also.
also I forgot to finish the errors in the last two line, here they are.
Dim badValue As Object = e.ProposedValue
e.ProposedValue = "Bad Data"
e.Row.RowError = "This field is limited to 'Mr.','Mrs.', 'Miss', or 'Dr.'"
e.Row.SetColumnError(e.Column, "Contact Title field is limited to 'Mr.','Mrs.', 'Miss', or 'Dr.'")
|
|
|
|
|
If I try to check that the value is either 'Mr' or 'Mrs' it wont work..
What am I missing?
ElseIf (CType(e.ProposedValue, String) <> "Mr") or (CType(e.ProposedValue, String) <> "Mr") Then
It works fine if I check for only "Mr"
code:
If CType(e.ProposedValue, String) = String.Empty Then
Dim badValue As Object = e.ProposedValue
e.ProposedValue = "Bad Data"
e.Row.RowError = "The Contact Title column contians an error"
e.Row.SetColumnError(e.Column, "Contact Title cannot be Empty")
' Do not allow if the value is not 'Mr'
ElseIf (CType(e.ProposedValue, String) <> "Mr") Then
Dim badValue As Object = e.ProposedValue
e.ProposedValue = ""
e.Row.RowError = "The Contact Title column contians an error"
e.Row.SetColumnError(e.Column, "Contact Title cannot be Empty")
|
|
|
|
|
Private Sub Customers_ColumnChanging(ByVal sender As Object, _
ByVal e As System.Data.DataColumnChangeEventArgs)
' Only check for errors in the Contact Title column
If (e.Column.ColumnName.Equals("Contact Title")) Then
Select Case CType(e.ProposedValue, String)
Case String.Empty
Dim badValue As Object = e.ProposedValue
e.ProposedValue = "Bad Data"
e.Row.RowError = "The Contact Title column contians an error"
e.Row.SetColumnError(e.Column, "Contact Title cannot be Empty")
Case "Mr."
e.Row.ClearErrors()
Case "Mrs."
e.Row.ClearErrors()
Case "Miss"
e.Row.ClearErrors()
Case "Dr."
e.Row.ClearErrors()
Case Else
Dim badValue As Object = e.ProposedValue
e.ProposedValue = "Bad Data"
e.Row.RowError = "The Contact Title column contians an error"
e.Row.SetColumnError(e.Column, "Contact Title is limited to 'Mr.','Mrs.', 'Miss', or 'Dr.'")
End Select
End If
End Sub
|
|
|
|
|
This may be of intrest to you.
Dim da As New OleDbDataAdapter
Dim da2 As New OleDbDataAdapter
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim ds As DataSet = New DataSet
Dim ds2 As DataSet = New DataSet
Dim strSQL As String
Dim strSQL2 As String
Dim cmSQL As OleDbCommand
Dim cmSQL2 As OleDbCommand
Dim conn As OleDbConnection = New OleDbConnection( _
"Provider = Microsoft.jet.oledb.4.0;Data source = D:\Program files\Microsoft Visual Studio .NET\Crystal Reports\Samples\Database\Xtreme.mdb")
If conn.State <> ConnectionState.Open Then conn.Open()
strSQL = "SELECT * FROM Customer"
cmSQL = New OleDbCommand(strSQL, conn)
da.SelectCommand = cmSQL
da.Fill(ds, "Customer")
DataGrid1.DataSource = ds.Tables(0)
strSQL2 = "SELECT * FROM [Orders Detail]"
cmSQL2 = New OleDbCommand(strSQL2, conn)
da2.SelectCommand = cmSQL2
da2.Fill(ds2, "[Orders Detail]")
DataGrid2.DataSource = ds2.Tables(0)
' add a new DataColumn Called "Total" to DataGrid2
Dim myColumn As DataColumn = New DataColumn
myColumn.DataType = System.Type.GetType("System.Decimal")
myColumn.AllowDBNull = False
myColumn.Caption = "Total"
myColumn.ColumnName = "Total"
myColumn.DefaultValue = 0
myColumn.Expression = "[Quantity] * [Unit Price]"
' Add the new DataColumn to the table.
ds2.Tables(0).Columns.Add(myColumn)
AddHandler ds.Tables(0).ColumnChanging, AddressOf Customers_ColumnChanging
End Sub
Private Sub ComputeByOrderID(ByVal myDataSet As DataSet)
' Presumes a DataTable named "Order Details" that
' has a new DataColumn named "Total".
Dim myTable As DataTable
myTable = myDataSet.Tables(0)
Dim objSum As Object
objSum = myTable.Compute("Sum(Total)", "[Order ID] > 0")
End Sub
Private Sub Customers_ColumnChanging(ByVal sender As Object, _
ByVal e As System.Data.DataColumnChangeEventArgs)
' Only check for errors in the Contact Title column
If (e.Column.ColumnName.Equals("Contact Title")) Then
Select Case CType(e.ProposedValue, String)
Case String.Empty
Dim badValue As Object = e.ProposedValue
e.ProposedValue = "Bad Data"
e.Row.RowError = "The Contact Title column contians an error"
e.Row.SetColumnError(e.Column, "Contact Title cannot be Empty")
Case "Mr."
e.Row.ClearErrors()
Case "Mrs."
e.Row.ClearErrors()
Case "Miss"
e.Row.ClearErrors()
Case "Dr."
e.Row.ClearErrors()
Case Else
Dim badValue As Object = e.ProposedValue
e.ProposedValue = "Bad Data"
e.Row.RowError = "The Contact Title column contians an error"
e.Row.SetColumnError(e.Column, "Contact Title is limited to 'Mr.','Mrs.', 'Miss', or 'Dr.'")
End Select
End If
End Sub
|
|
|
|
|
Hi all,
I have the following problem: i got an ip (such as 209.89.34.23) which associated with a computer current online. How can I get all available information of this computer by using VB and which API should be used?
I know the function gethostbyaddr when i implemented it to get hostname of local network, working correctly. But when use it to get hostname from an internet IP, is not working and raise following error "Valid name, no data record of requested type."
What should i do to get all available information of computer i got the IP
|
|
|
|
|
What do you mean by "all available information"? Are you talking about getting any DNS record for the IP address?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
all available information here is can be:
- Opened ports
- Domain
- NetBIOS name
- Groups
- Users
- Transport
- Share
I have a question for scan algorithm.
Scenarion:
1) User input IPs range (from IP -> to IP).
2) Application scan the range and return live host associated with IP in range
3) Gather information about IP scanned
Can you show me the way to do this? I mean how to scan and how to find the live host associated with its (with code for scaning process is very helpful)
|
|
|
|
|
THen you going to need to use WMI and the System.Management namespace to get at the information. There is no one function call you can make to do this. It's going to be alot of code to write because you looking to get all kinds of dissimilar information.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
When use WMI, the target computer must have WMI installed too rite? I want to check every possible getted information. You know what i mean. If there anything available to get, just get other wise do nothing. Therefore, i think should not use WMI.
How about your opinion?
|
|
|
|
|
In that case, most of the information you want is not available without writing a client inventory application that must be running on each client machines you want to scan. For that app, you'll have to write LOTS, and I mean A LOT, of code to get each little piece you want and put it together into a form that you can transfer to the server machine collecting this data.
WMI is the ONLY way to go for this if you want to keep the code down to a minimum... Granted, WMI is not available without installing software for it on WIndows NT SP3, Me, 98, 95 and below. Windows 2000 and above come with WMI standard.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thank Dave for remine me, sound good!
I agree that we must use WMI to get information. Now i wonder how can i do that. I mean, i'm a newbie to do that. Can you show me the way to check for all available port and other information by using WMI (working on Win2K SP4) and programming in VB6
|
|
|
|
|