Example:
Dim Conn as New OledbConnection(ConStr)
con.Open()
Dim Save as New OledbCommand("INSERT INTO Client(Nom,Prenom,Adresse,Téléphone,date) VALUES(@p1,@p2,@p3,@p4,@p5)",Conn)
'Add parameters'
Save.ExecuteNonQuery()
Example:
Dim Conn as New OledbConnection(ConStr)
con.Open()
Dim Save as New OledbCommand("INSERT INTO Client(Nom,Prenom,Adresse,Téléphone,date) VALUES(@p1,@p2,@p3,@p4,@p5)",Conn)
'Add parameters'
Save.ExecuteNonQuery()
You will need to make use of the Microsoft Office Interopt libraries if you are wanting to manipulate a workbook that is not open.
Access is a single user application, therefore; it is not possible.
You might want to look into SQL or MySQL as an alternitave if you are wanting multiple users.
Yep, if you want to check all of the radio buttons at once (Only allowing one answer/click) you will want to do the follwing:
AddHandler RadioButton1.Click, AddressOf RBC
AddHandler RadioButton2.Click, AddressOf RBC
AddHandler RadioButton3.Click, AddressOf RBC
AddHandler RadioButton4.Click, AddressOf RBC
Then place the IF code in the RBC Sub, checking for which radio button was clicked.
To check which control sent the action, make use of the sender object.
You will need to create the sub for the click and then add the handler on runtime.
Example:
AddHandler RadioButton1.Click, AddressOf RBC
Private Sub RBC(sender As Object, e As EventArgs)
'Place code here
End Sub
One alternative is to place an open file dialog in the project, then allow the user to navigate to the data base.
You will:
1) Place the dialog
2) Do some coding to prevent empty paths
3) Store the value from the dialog on the form.
4) Create a backup button that will execute the backup.
You can also ad a Folder Browser Dialog to the project, to allow the user to chose where the backup will be placed
Code example:
Dim SourceDir As String
Dim DestDir As String
If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
If OpenFileDialog1.FileName <> "" Then
SourceDir = OpenFileDialog1.FileName
End If
End If
If FolderBrowserDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
If FolderBrowserDialog1.SelectedPath <> "" Then
If IO.Directory.Exists(FolderBrowserDialog1.SelectedPath) Then
DestDir = FolderBrowserDialog1.SelectedPath & "/" 'Must add the / to end.'
End If
End If
End If
Use the command to fill a data adapter, and port that into a data table.
Then cycle through the data table and pass those values in.
Example:
Dim da As New SqlDataAdapter
Dim ds As New Data.DataSet
Dim dt As New Data.DataTable
da.SelectCommand = MyCommand
da.Fill(ds, "myitems")
dt = ds.Tables("myitems")
For i = 0 To dt.Rows.Count - 1
message.Body &= vbCrLf & dt.Rows(i).ToString
Next
What you will need to do is:
1) Loop through the workbook, comparing and storing all values that reference that person.
2) Loop through those values, adding them to the message (body?)**
It may be easier to write the values to a text file and attach the text file to the message.
It is possible to have security permissons denying writing to the root of a drive.
Also, are you getting the data from notepad or something of the sort?
I have this feeling that Iamature is begging for homework.
As Mitja stated, he has posted the same question, re worded, at least twice.
He also PM'ed me, asking for me to code his project for him.
I don't mind helping, but doing the work for someone is a different story.
Give a man a fish, he will eat for a day. Teach a man to fish, he will eat for a lifetime.
I have a class for RS232 still, but I don't think that will help you any. :P
EDIT
Or would it....
Does anyone know if RS232 API will work with USB?
They are both "serial" ports.
I will do some research to see if I can find some other references for you.
So you had to use date?
Sure, if you don't mind.
What form border style are you using?
I know I have had some issues when desinging in Sizable and then changing it to Fixed3D ect..
Are these controls placed inside another? ie. Panel, Groupbox ect..
Do you have any code in the form's resize event or any code anywhere that changes their location?
Also, is the screen resolution any different when debugging/release?
Soon enough a mod wil come move it for you. Normally takes about 2/3 hours for one to see it.
Sorry for the long reply.
I am trying to recreate your problem.
Ok. Just remeber that for every control that contains other controls, you will need another For loop.
You will want to subtract one from QuestHistroyArray length
You will always want to subtract 1 from an array.
The last item will be a terminator character, so you will want the n - 1 index.
Np friend, anything else I can help you with?
You could create a boolean check.
Example:
Dim canExecute As Boolean = False
'From the ComboBox's indexChanged event, do the following:'
If ComboBox1.SelectedValue = "A" Then
canExecute = True
End If
'From the Button's click event, do the following:'
If canExecute = True Then
'My Code Here'
End If
Is this what you are looking for?
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
Something like this:
Dim conStr As String = "Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;"
Dim con As New SqlConnection(conStr)
Dim cmd As SqlCommand
Try
Dim myValue As String = "This is a test."
con.Open()
Dim sqls As String = "INSERT INTO table (column) VALUES ('" & myValue & "')"
cmd = New SqlCommand(sqls, con)
cmd.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.Message)
End Try
You could write a sql statement to instert each one, then place it in a loop.
Example:
Dim conStr As String = "Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;"
Dim con As New SqlConnection(conStr)
Dim cmd As SqlCommand
Try
For i = 0 To ComboBox1.Items.Count
con.Open()
Dim sqls As String = "INSERT INTO table (column) VALUES ('" & ComboBox1.Items(i).ToString & "')"
cmd = New SqlCommand(sqls, con)
cmd.ExecuteNonQuery()
Next
Catch ex As Exception
MsgBox(ex.Message)
End Try
Seduction is her game.
Lying
Gum Kazakastan Llama
lag -> internet
Because he owns a Ford Pinto
Why did the chicken cross the road?
No problem friend, any other issues you have?
Here is a tiny little recursive sub procedure I have written to do what you are needing it to do.
Public Sub PlusOne(int As Integer)
If int <= 1000 Then
ListBox1.Items.Add("HelloWorld")
int += 1
PlusOne(int)
End If
End Sub
Just need to pass 1 in as int when you first call the sub, and change ListBox1 to Console.WriteLine.
There are a number of ways to do what thines is saying.
Are you parseing the data in line by line or the entire file?
Are you storing the data in a single string or in an array?
For loops are actualy pretty easy to use.
Example:
For Each object In Collection
Next
For Each Control in Me.Controls
'Loops through every control on the form.'
Next
For i = 0 to Me.Controls.Count
Next
'Would be the same as coding'
for(i=0;i=Me.Controls.Count;i++)
{
}
Hope this helps.
Example:
Dim sqls As String = "SELECT column1 FROM table WHERE primarykey=value"
Example:
Dim sqls As String = "INSERT INTO table (column1) VALUE ('" & DateTimePicker1.Value & "')"
It would work.
If you wanted to remove it later you could try:
t.RemoveAt(t.IndexOf(txtField4))
Does anyone have anything else to add to the discussion?
If not, I will go ahead and close the thread.
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. :)
Your If statement is convlicting with what you are wanting.
You are checking to see if the row is not empty, and checking to see if string value is not empty.
Then removing it when it satisfies both conditions.
I think what you are looking for is:
If IsNothing(row.Cells(j).Value) = true AND row.Cells(j).Value.ToString = "" Then
DataGridView1.Rows.RemoveAt(i)
End If
Also, from what I see, you are only removing the row at position 0.
Are you incrementing your index, i?
One more thing.
If you are wanting to cycle through the entire row, your code should look somthing like this:
Dim i As Integer = 0
Dim mtCell As Integer = 0
For Each row As DataGridViewRow In DataGridView1.Rows
For j = 0 To row.Cells.Count
If IsNothing(row.Cells(j).Value) = True And row.Cells(j).Value.ToString = "" Then
mtCell += 1
End If
Next
If mtCell = row.Cells.Count Then
DataGridView1.Rows.RemoveAt(i)
End If
i += 1
mtCell = 0
Next
You will have to right a for/each loop for each sub level.
Each level is considered it's own collection.
Example:
For Each i As Control In Me.Controls
For Each j As Control In i.Controls
For Each k As Control In j.Controls
If TypeOf k Is TextBox Then
End If
Next
If TypeOf j Is TextBox Then
End If
Next
If TypeOf i Is TextBox Then
End If
Next
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.
I have used WinForms primarily, but have attempted a few small projects with WPF.
My biggest issue is the taxation on hardware. Not everyone has an up to date pc.
Heck, I still know people who are on Windows 98. D:
I agree, I do not like that Microsoft is tossing winforms for WPF.
Seems to me like they are leaning more and more torward the "Metro Mindset".
I personally could care less what an app LOOKs like, it's about the programming and logic behind the app.
WPF just seems like it is getting more and more taxing on hardware.
Ofcourse, it looks good, but you pay for looks.
cough Apple cough