Are you sure the path is correct?
You can verify it by doing this:
If File.Exists("C:\Users\Abdueie\Desktop\BMS\Bridge Asset Management\Bridge Asset Management\bin\Debug\Adigrat.accdb") Then MsgBox("It is there!") Else MsgBox("Path May Be Wrong!")
Are you sure the path is correct?
You can verify it by doing this:
If File.Exists("C:\Users\Abdueie\Desktop\BMS\Bridge Asset Management\Bridge Asset Management\bin\Debug\Adigrat.accdb") Then MsgBox("It is there!") Else MsgBox("Path May Be Wrong!")
Any time you have values being loaded in to memory, you run the risk of slowing down a process.
I suggest a small database backend to store the words/meanings/sample sentences. Then perform a lookup when needed.
For example:
----------------------------------------------------------------
|__________________________tblWords____________________________|
|_____ID_____|______Word ____|______Type______|____Sentence____|
| Identity | VarChar(50) | VarChar(100) | VarChar(500) |
----------------------------------------------------------------
This will give you a lookup table, where you can store values similar to this:
0 , abo , Adverb , to come along with sb. Annii ageen ho paze atu si abo mondo.(the duckling is coming with its mother).
1 , abi , , to come on behalf of other.
This table will store ALL of your words/definitions.
Then to get the definition, just query the database:
Dim myCon As New OleDBConnection("MyConnectionStringHere") 'See www.ConnectionStrings.com
myCon.Open()
'Assumes words are unique in spelling in database.
Dim da As New OleDBDataAdapter("SELECT * FROM tblWords WHERE Word=@Word",myCon)
da.SelectCommand.Parameters.AddWithValue("@Word",TextBox1.Text)
Dim ds As New DataSet
Try
da.Fill(ds,"Definitions")
If ds.Tables("Definitions") IsNot Nothing And ds.Tables("Definitions").Rows.Count > 0 Then
With ds.Tables("Definitions")
TextBox2.Text = TextBox1.Text
TextBox3.Text = .Rows(0)("Type")
TextBox4.Text = .Rows(0)("Sentence")
End With
End If
Catch ex As Exception
MsgBox(ex.ToString)
End Try
This will force the database to do most of the work, and allow your code to run smoother by removing the HUGE nested if that is there.
You could loop through the values and check if they are equal:
For i As Integer = 0 To dataGridView1.Rows.Count - 1
For j As Integer = 0 To dataGridView1.Columns.Count - 1
If IsNothing(dataGridView1.Rows(i).Cells(j).Value) = False And YourStringValueHere = dataGridView1.Rows(i).Cells(j).Value.ToString() Then
'Item found
Exit For
End If
Next
Next
There will be many different options for data manipulation.
You can use bound controls.
You can use GridViews.
You can use ListViews.
You can use Reporting.
Here is a very good article you might want to read. It will cover the basic concepts of databinding.
I hope this helps!
And it appears that my first copy/paste attempt of the first code snippet is missing the lstString type.
lstString is declared at a List(Of List(Of String))
Dim lstString As List(Of List(Of String))
My appologies.
You could split the line using the String.Split function and reference the index of that value.
Example:
Dim sr as New StreamReader("MyPath")
Dim da As New OleDbDataAdapter("SELECT * FROM myTable", "MyConnectionString")
Dim dt As New DataTable
da.Fill(dt)
'This will loop until every line is read.
Do While sr.Peek <> -1
lstString.Add(sr.ReadLine.Split(",").ToList)
Loop
'To reference the values for insert, do something like this:
'Set index to 1 to skip first row (headers)
For i = 1 To lstString.Count - 1
Dim dr As DataRow = dt.Rows.Add
dr("Column1") = lstString(i)(4) 'Where 4 is the index of the column ***REMEMBER THAT ARRAYS ARE ZERO BASE
dr("Column2") = lstString(i)(7)
Next
da.UpdateCommand = New OleDbCommandBuilder(da).GetUpdateCommand
da.Update(dt)
I would check your new statements:
Dim ds As New DataSet9.
Dim apt As New SqlDataAdapter
apt = New SqlDataAdapter(sqlstr, constr)
As these may be looking for parameters that you are not passing in correctly.
My suspicion is on this statement:
apt = New SqlDataAdapter(sqlstr, constr)
I believe you may have your to change your parameters.
After reading the code tag, it looks like the contructor wants:
*New(selectCommandText as String, selectConnectionString as String)*
When you are passing in a string/OLEDB Connection
Which warrants the question, why are you cross calling the SQLClient and OLEDB libraries?
You can do as Jim has said and shave a VERY small amount of time off by placing everything inside of the If statement:
If MsgBox("Do you want to Delete?", MsgBoxStyle.YesNo, "Confirm") = MsgBoxResult.Yes Then
Dim cmd As new OleDBCommand("",con)
cmd.CommandText = "DELETE FROM [" & EBU2DB_LOB & "] " _
& " WHERE Brand = ? " _
& " AND LOB = ? " _
& " AND Months = ? "
cmd.Parameters.AddWithValue("@Brand ", Form_Month_End_Report.Combo_LOB_Brand.Text)
cmd.Parameters.AddWithValue("@LOB ", Form_Month_End_Report.Combo_LOB_LOB.Text)
cmd.Parameters.AddWithValue("@Months", Form_Month_End_Report.Combo_LOB_Month.Text)
If con.State = ConnectionState.Closed Then con.Open()
cmd.ExecuteNonQuery()
End If
This will only create the command and set the command text when you want to delete the item.
Upon resizing an anchored combobox - I noticed the text was always selected.
This sparked the initiative to fix this problem. (Microsoft decided not to)
So by extending the combobox class we can fix this.
The following class can be dropped into a form for designer manipulation or as a user control.
This is an extremely simple fix.
You might also want to look into using a data adapter do reduce the amound of code you have.
For example:
Private Sub UpdateData()
'You can place your select statment here...
'Don't worry about selecting certian columns... you will only edit the ones you want in the code below.
Dim da As New OleDB.OleDBDataAdapter(New OleDB.OleDBCommand("SELECT * FROM MyTable WHERE Column=Value",myConnection))
Dim ds As New DataSet
Try
'If your connection is not open, do so before calling this.
da.Fill(ds,"MyTable")
If IsNothing(ds.Tables("MyTable")) = False Then
'If you create a new row - you call insert, if you modfiy an existing row - call update.
Dim dr As DataRow = ds.Tables("MyTable").Rows.Add
With dr
'Place your statements here.
'Example:
dr("Column1") = TextBox1.Text
End With
'If Update
da.UpdateCommand = New OleDb.OleDbCommandBuilder(da).GetUpdateCommand
'If Insert
da.InsertCommand = New OleDb.OleDbCommandBuilder(da).GetInsertCommand
'NOTE - A PRIMARY KEY MUST BE PRESENT IN THE TABLE.
da.Update(ds.Tables("MyTable"))
Else
MsgBox("Could not retreive table data!" & vbcrlf & "Process aborted!")
Exit Sub
End If
Catch ex As Exception
MsgBox(ex.ToString())
Finally
'Can close here if needed/wanted
myConnection.Close()
da.Dispose()
ds.Dispose()
End Try
End Sub
I am not fully understanding your question.
If you are asking for the code you are so close.
Something like this:
If ComboBox1.Text.Contains("x") Then
Dialog1.ShowDialog()
End If
If not, then what ARE you asking?
Please explain in more detail.
Upon aiding a friend - I have decided to post the example used here.
The following is a snippet that shows basic class inheritance.
The source file as well as a test case can be found attached.
You can test these classes with the following code:
Dim cNew As New Car
Dim vNew As New Van
Dim tNew As New Truck
With cNew
.Make = "Chevrolet"
.Model = "Camaro"
.Engine = 6.0
.Year = 2013
.Style = Car.StyleOption.Coupe
MsgBox(.ToString)
End With
With vNew
.Make = "Chevrolet"
.Model = "Express"
.Engine = 6.0
.Passengers = 4
.Year = 2013
.Cargo_Rack = True
.Folding_Seats = False
MsgBox(.ToString)
End With
With tNew
.Make = "Chevrolet"
.Model = "Silverado"
.Engine = 6.0
.Year = 2013
.Cab = Truck.CabSize.Crew_Cab
.Torque = 413
MsgBox(.ToString)
End With
No, the .Net framework/Oracle takes care of the rest for you. (Provided you coded the application correctly)
You can use this for Microsofts instructions on setting the folder cache.
The example is for Windows Server 2008, which I'm sure you can do the same for Windows 7.
What do you mean by item analysis?
What kind of items are you wanting to analyze?
As for the code, we can't GIVE you code - We aren't a DO forum we are a HELP forum.
The code from the post above will test the value in the textbox before entering it into the listbox.
This should accomplish what you are wanting, as for the guessing part, you will have to drop your code in.
I hope this helps. :)
You could try to add it to an array then search the array for it:
Dim lstString As New List(Of String)
'Assuming they have to press a button to submit their letter
Private Sub Button_Click(sender as object, e as eventargs)Handles Button1.Click
If lstString.BinarySearch(ListBox1.Text.ToLower) <> -1 Then
MsgBox("You can only enter a letter once!")
Else
lstString.Add(ListBox1.Text.ToLower)
End If
End Sub
You could do that, or create flow layout panel containing the buttons for A-Z and disable the button on click.
If you are popoulating the listbox with a dataset, you just need to refresh the data.
What connection type are you using?
Try This:
Dim MyTable As String
MyTable = "Table1"
For i = 0 To ds.Tables(MyTable).Rows.Count - 1
'Do Work
Next
A label does not have a MaxLength Property, but it would probably be safe assumtion that it's a 32bit integer number.
So a label would have 2^32 maximum characters. (4294967296 possible characters)
EDIT
Here is a link that leads to an article with a custom marquee control.
You are going to need a database backend for your application.
You will need to do the following:
1)Compose a list of things you need to store and keep track of.
a)Inventory
b)Customers
c)Ect...
2)Tear down the storage items to their most simple (atomic) state to create your tables.
a)Lookup Tables
b)Foreign Keys
c)Ect...
3)Find which database type fits your needs.
a)SQL Server
b)Oracle
c)Access
d)Ect...
4)Design your application by flowcharting then coding. ( Never code first!)
5)Design the GUI (Design it for the user, not for your preference)
6)Write/Debug the code
Now, with that being said...
You will have to determine how many user will be using this software.
If you are expecting multiple users, do not use Access as your database.
Access is a single user only database.
When connecting the database to the Application, you will have to determine what library you chose to use as the method. For example:
You will need to learn the methods of creating a connection to the database.
Here is a great resource!
You will also need to study data manipulation (DataAdapters,DataSets,DataTables ect..)
I hope this points you in the right direction!
You will want to make use of the FullName property.
Example:
Dim di As New IO.DirectoryInfo(YourDirectoryHere)
Dim diar1 As IO.FileInfo() = di.GetFiles()
Dim dra As IO.FileInfo
For Each dra In diar1
If dra.Extension = ".csv" Then
fileCreatedDate = File.GetCreationTime(dra.FullName)
End If
Next
You can do something like this:
Dim di As New IO.DirectoryInfo(YourDirectoryHere)
Dim diar1 As IO.FileInfo() = di.GetFiles()
Dim dra As IO.FileInfo
For Each dra In diar1
If dra.Extension = ".csv" Then
'Do Work
End If
Next
Try this:
Dim lstCourses As New List(Of Course)
This will create a list, you can add and remove elements like this:
lstCourses.Add(Courses1)
lstCourses.Remove(Courses1)
If the declaration is in anything private than it is in accessable.
Can you post the bit of code for the declaration?
The best solution would be to check for a forum for the addin.
Something the developer uses for a "tech support" web site.
As for vb.net, you may have problems going from LTR languages to RTL languages and visa versa.
Try this instead:
For remove use the following:
listview6.Items.Remove(listview6.SelectedItems.Item(0))
'If multiple items are selcted use
For each itm as ListViewItem in ListView6.SelectedItems
listview6.Items.Remove(itm)
Next
You can also create one function using Jim's method:
Private Sub FocusChanged(sender As Object, e As EventArgs)
If CType(sender, TextBox).Focused = True Then
CType(sender, TextBox).BackColor = Color.FromArgb(65, 65, 65)
ElseIf CType(sender, TextBox).Focused = False Then
CType(sender, TextBox).BackColor = Color.FromArgb(60, 60, 60)
End If
End Sub
And just add the handlers to each textbox:
'Add this code in the form load event'
For Each txt As TextBox In Me.Controls
AddHandler txt.GotFocus, AddressOf FocusChanged
AddHandler txt.LostFocus, AddressOf FocusChanged
Next
You can use what hericles has posted and append the following:
Dim con As New SqlConnection("Connection string here")
con.Open()
Dim sqls As String = "SELECT col_name1, col_name2 FROM table_name WHERE some_col = some_value;"
Dim cmd As New SqlCommand(sqls, con)
Dim da As New SqlDataAdapter(cmd)
Dim ds As DataSet
da.Fill(ds, "Values I Need")
Dim dt As New DataTable
dt = ds.Tables("Values I Need")
If dt.Rows.Count > 0 Then
For i = 0 To dt.Rows.Count - 1
TextBox1.Text = dt.Rows(i).Item(0) 'col_name2'
TextBox1.Text = dt.Rows(i).Item(1) 'col_name2'
Next
End If
I have not tried it before, but you can make use of ReDim Preserve.
You can recreate the array every time it is needed.
You could try something like:
Dim curItem as Integer = 3
ar.RemoveAt(3)
For i = CurItem to ar.Count - 2
ar(i) = ar(i + 1)
Next
ar.RemoveAt(ar.Count - 1)
This will "push" everything up one, then delete the last one.
Hello my fellow Daniwebers.
I am to ask for some ideas for a challenge.
I want a good challenge for my skills, and even help expand my skills
Please post your challenge below.
Thanks,
Begginnerdev
If you are not getting a reply - Don't make a new thread.
This would be your fourth thread on the same topic.
You can't beg community members for code, you have to show effort on your behalf.
I know people have posted usefull references numerous times, why have you not tried them?
Or, have you tried them and they have not worked?
If they have not worked, why not?
I beleive you have chosen the wrong template for your thread.
Code snippets are mostly used for posting examples or contributing code to the community.
Also, I don't want to sound skiddish at all.....but what would you possibly want to hide a process for?
Are you writing a keylogger?
Are you writing a program for a"joke" on some one else?
Another note, for the active - You can fill a context menu with the possible solutions and allow the user to click the one they want.
For active:
1) Capture each character typed and query the database for possible solutions.
For passive:
1) The user leaves the text box, check against the database by splitting spaces and storing in the array.
Example of active:
Dim s As String = ""
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
'cmd = Command '
'da = Data adapter'
'ds = Data set'
'dt = Data table'
s = TextBox1.Text
Dim sqls As String = "SELECT * FROM table WHERE value='" & s & "'"
cmd = New Command(sqls,con)
da.SelectCommand = cmd
da.Fill(ds,"table1")
dt = ds.Tables("table1")
If dt.Rows.Count > 0 Then
return
Else
TextBox1.BackColor = Color.Salmon
End If
End Sub
For the passive:
Dim ar() As String
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
'cmd = Command '
'da = Data adapter'
'ds = Data set'
'dt = Data table'
ar() = TextBox1.Text.Split(" ")
For i = 0 to ar.Count - 1
Dim sqls As String = "SELECT * FROM table WHERE value='" & ar(i) & "'"
cmd = New Command(sqls,con)
da.SelectCommand = cmd
da.Fill(ds,"table1")
dt = ds.Tables("table1")
If dt.Rows.Count = 0 Then
'place your code here for letting the user know it's misspelled.'
Next
End Sub
Are you wanting an active spell check? (One that checks as you type)
or
Are you wanting a passive spell check? (One that checks the word after you type it)
For one thing, I never see you fill the data set with the data adapter.
Example:
da.Fill(ds,"tableName")
This does something very close to what you want, try to use this as a reference.
Dim j As Integer = CInt(TextBox1.Text)
Dim numOfPasses As Integer = j
Dim numbers() As String = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}
For i = 0 To j
Dim lineString As String = ""
numOfPasses = i + 1
While numOfPasses <> 0
lineString &= numbers(numOfPasses)
numOfPasses -= 1
End While
ListBox1.Items.Add(lineString)
Next
Np friend, anything else I can help you with?
For one thing,
myDa.Fill(mydataset, "Old_info")
and
search_data_DataGridView.DataSource = mydataset.Tables("Old_inf0").DefaultView
Are refrencing two different tables.
You have a zero placed at the end of
search_data_DataGridView.DataSource = mydataset.Tables("Old_inf0").DefaultView
It would work.
If you wanted to remove it later you could try:
t.RemoveAt(t.IndexOf(txtField4))
I forgot to add, to retrieve the object from the ArrayList, it's good practice to do the following.
Dim txtBox As TextBox = TryCast(t(i), TextBox)
Dim lbl As Label = TryCast(l(i),Label)
If the cast fails, they will return Nothing.
So by just checking to ensure they are not nothing, you will safeguard from null references.
Here is a rewritten version of your code using ArrayLists (better when dynamicly adding/removing from a list/array)
Dim t As New ArrayList
Dim l As New ArrayList
For i = 0 To intNoColumns - 1
Dim lbl As New Label
Dim txt As New TextBox
lbl.Name = "lblField" & i
lbl.Location = New Point(25, intylocation)
lbl.Size = New Size(300, 15)
lbl.Text = dt.Columns(i).ToString
Me.pnlResults.Controls.Add(lbl)
txt.Name = "txtField" & i
txt.Location = New Point(150, intylocation)
txt.Size = New Size(300, 10)
txt.Text = dt.Rows(intCurrentRecord).Item(i)
If lbl.Text = strPrimaryKey Then
txt.Enabled = False
intPrimaryKeyIndex = i
End If
Me.pnlResults.Controls.Add(txt)
intylocation += 50
t.Add(txt)
l.Add(lbl)
Next
This will be must easier for you to use than using redim for each new item in the array.
You might also want to wrap your code in try/catch blocks.
I think what thines is trying to say is you will have to post some code so we can look at it.
We can't exactly tell what's going wrong if we can't see your code. :)
You will have to change your command strings.
Any STRING that is being entered into a command should be wrapped in `'s.
Example:
SELECT * FROM book WHERE isbn='" & Cstr(intISBN) & "'"
You just need to fix your queries.