|
Ho interesting stuff, I did not think there were... no I'll just shut up now. However I did add some commentary to Colin's response!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
The fact that Latin is not extinct does not mean that we should write manuals in it.
It is an unsupported language - all those open source projects might stop working tomorrow due to some windows-update. People will be whining about Microsoft, while they've had more then ten years to migrate.
It's as much as a feasable target for development as the Atari ST environment; while there still may be some enthousiast playing with it, we do not consider them to be 'active' platforms.
VB6 is not pinin' - it is bereft of life, it has ceased to be, it is an ex-language.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I have multiple combobox which pulls all its information from several sql tables. The records are being populated but unable to insert into a sql table (tran_log) once data's are selected. I found a scripts which prompts me that I have a successful connection to my DB and that an insert has been made but the records are not being updated. I tried 2 different scripts but still no luck. Also, I get an error regarding objcmd.ExecuteNonQuery() from both scripts that's why its commented. Thanks!
Script 1:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim acsconn As OleDbConnection = New OleDbConnection _
("provider=SQLOLEDB;data source=DBserver;database=myDB;user ID=user;password=mypassword;")
acsconn.Open()
If acsconn.State = ConnectionState.Open Then
MsgBox("Connected")
Dim strsql As String = "insert into tran_log(hw_name,[type],[status],wh_function,[user],check_out_date)values(?,?,?,?,?,?);"
Dim objcmd As New System.Data.OleDb.OleDbCommand(strsql, acsconn) ' the oledbcommand
With objcmd
.Parameters.AddWithValue("@ComboBox1", ComboBox1.SelectedItem)
.Parameters.AddWithValue("@TextBox1", TextBox1.SelectedText)
.Parameters.AddWithValue("@ComboBox2", ComboBox2.SelectedItem)
.Parameters.AddWithValue("@ComboBox3", ComboBox3.SelectedItem)
.Parameters.AddWithValue("@ComboBox4", ComboBox4.SelectedItem)
.Parameters.AddWithValue("@DateTimePicker1", DateTimePicker1)
End With
Try
objcmd.Connection.Open()
Dim rowsAffected As Integer = objcmd.ExecuteNonQuery()
Console.WriteLine("RowsAffected: {0}", rowsAffected)
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
'objcmd.ExecuteNonQuery()
objcmd.Dispose()
MsgBox("Saved")
End If
acsconn.Close()
End Sub
Script 2:
Dim strcom1 As String = ComboBox1.SelectedText
Dim strcom2 As String = TextBox1.SelectedText
Dim strcom3 As String = ComboBox2.SelectedText
Dim strcom4 As String = ComboBox3.SelectedText
Dim strcom5 As String = ComboBox4.SelectedText
Dim strcom6 As New DateTimePicker()
Dim objconnection As OleDb.OleDbConnection = Nothing
Dim objcmd As OleDb.OleDbCommand = Nothing
Dim strconnection As String, strSQL As String
strconnection = "provider=SQLOLEDB;data source=DBserver;database=myDB;user ID=user;password=mypassword;"
objconnection = New OleDb.OleDbConnection(strconnection)
objconnection.ConnectionString = strconnection
objconnection.Open()
strSQL = "insert into tran_log(hw_name,[type],[status],wh_function,[user],check_out_date)values(@ComboBox1,@TextBox1,@ComboBox2,@ComboBox3,@ComboBox4,@DateTimePicker);"
objcmd = New OleDb.OleDbCommand(strSQL, objconnection)
objcmd.Parameters.Add(New System.Data.OleDb.OleDbParameter("@ComboBox1", strcom1))
objcmd.Parameters.Add(New System.Data.OleDb.OleDbParameter("@TextBox1", strcom2))
objcmd.Parameters.Add(New System.Data.OleDb.OleDbParameter("@ComboBox2", strcom3))
objcmd.Parameters.Add(New System.Data.OleDb.OleDbParameter("@ComboBox3", strcom4))
objcmd.Parameters.Add(New System.Data.OleDb.OleDbParameter("@ComboBox4", strcom5))
objcmd.Parameters.Add(New System.Data.OleDb.OleDbParameter("@DateTimePicker", strcom6))
objconnection.Close()
MessageBox.Show("Entered Successfully!")
|
|
|
|
|
Gentry_38 wrote: Also, I get an error regarding objcmd.ExecuteNonQuery() from both scripts that's why its commented.
If you don't execute the command, then it's no surprise that the command won't be executed, and your database won't be updated!
You need to call the ExecuteNonQuery method, so concentrate on fixing the error. If you can't fix it yourself, post the details of the error here and someone will probably be able to help you with it.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I removed the comment got the error "Invalid character value for cast specification".
|
|
|
|
|
Then one of the values you're trying to insert is not valid for the column you're trying to insert it into. Debug your code, inspect the values of the parameters, and compare them to the data types of the relevant columns.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Figured it out. Just had to change the value to .Text. Thanks for your help!
Dim strcom1 As String = ComboBox1.Text
Dim strcom2 As String = TextBox1.Text
Dim strcom3 As String = ComboBox2.Text
Dim strcom4 As String = ComboBox3.Text
Dim strcom5 As String = ComboBox4.Text
Dim strcom6 As DateTime = DateTimePicker1.Value
|
|
|
|
|
I have two options. When option single is checked, Iwant to show a openfiledialog and read it contents and save it in database as Byte.
When the option multiple is clicked, Want to open a folderbrowserdialog, want to read all files and its contents and save it in the database. How to acheive this??
|
|
|
|
|
In option 1 you just read the file whose path is returned from the OpenFileDialog, and write the data as required. In option 2 you set a loop and iterate over all the files in the selected folder, doing the same for each file. It is unlikely that you would want to save each file's content in the database, unless they are fairly small files, or you have unlimited disk space in your database. A possible solution is to write the file contents in some other folder, and save their locations in the database. What exactly is the problem in implementing this?
Veni, vidi, abiit domum
|
|
|
|
|
hi my my name is vishal.i am exporting vb6 data to PDF using sql select query from multiple tables.. My form is loads appropriate agn numbers. However here is line below where i get error saying:item cannot be found in the collection corresponding to the requested name or ordinal.
given below is line in sql select query where i get error:
MDIForm1.loadReportinPDF "select iw.agn,ih.item_name,iw.no_of_bundle,sw.rack_name,sw.store_no from Inward iw,item_master ih,store_master sw where iw.deleted_status=ih.deleted_status", "STOCK PURCHASE-SAMPLE"
Can anyone point out how should i fix this problem.Can anyone help me please.Any help would be greatly appreciated.
|
|
|
|
|
That error usually means that you have a spelling mistake in one of the column names in the query
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
Firstly thank you for replying on such short notice Mam/Sir i have checked my column names and i have typed correctly in sql select query.I will given you structure of my 3 tables(Inward,item_master,store_master) given below:
table name:Inward
Field Name DataType
mfr_ref_number Text
no_of_bundle Integer
supplier_id Integer
DC_date Date/Time
INV_date Date/Time
row_upd_date Date/Time
courier_name Text
inward_type Text
user_id Long Integer
deleted_status Yes/No
deleted_date Date/Time
DC_NO Text
closed_status Yes/No
closed_date Date/Time
store_no Long Integer
to_dept Text
agn AutoNumber
table name:item_master
Field Name DataType
user_id Long Integer
row_upd_date Date/Time
deleted_status Yes/No
status Yes/No
item_name Text
item_parent Long Integer
item_price Double
item_desc2 Memo
item_desc1 Memo
item_desc3 Memo
item_type Long Integer
item_code Text
agn AutoNumber
measure_type Text
table name:store_master
Field Name DataType
rack_name Text
rack_desc Memo
user_id Long Integer
row_upd_date Date/Time
status Yes/No
store_no AutoNumber
Sir above i have posted the structure of my 3 tables.Tell me or guide me,correct me where i am going wrong in the sql select query? Reply please.
|
|
|
|
|
Creating tables in Access using the above definitions, and running your query after cutting and pasting, it works first time.
I am confused, however by the fact you have no joins between the tables in the query, and by how the tables are related.
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
Hi All!
Hello all!
It’s been awhile and I’m back with another odd ball application.
I’ve never played much with Visual Studio 2013 and DOS. I’m starting with a plane-Jane form, nothing special.
I have a need to create an application that will use DOS. I know, DOS! Yes. It’s still used very widely.
What I need to do is:
1.) Have text box where I can enter a server IP
2.) Have a text box where I can enter a time in minutes. This Text box will be controlling a Timer function.
3.) Have a check box that will enable the timer
4.) Have a start button that will start the timer (based on the contents in the text box for time)
5.) A stop button to Stop the Timer cycle
6.) And finally a TEST button
What does this all do? Pings a server of the IP I entered into text box 1.
I’m working with a remote router that likes to fall asleep. Boss wants me to come up with a way we can enter the router’s IP addy, select a time in minutes and “Ping” this thing ever so many minutes.
I’ve included the form layout and am not sure exactly where to start. I’d like a text box to display the results of the ping when I click the test button as well.
So, I guess the first task is:
How can one enter an IP addy into a text box and tell DOS to Ping that IP addy and display that result in a text box?
Please let me know if this is not the right forum, it’s been a few years since I’ve been on here. Any help will be greatly appreciated.
Thanks in advance, these forums have helped me in some very odd ball projects in the past. I’d like to work through the entire project on here in this thread. Things discovered in this project could really be helpful to others.
Thanks,
-Chris
|
|
|
|
|
I'm assuming the reference to DOS is simply because you want to execute the ping command, which runs in a command-prompt?
If so, you can use the System.Net.NetworkInformation.Ping class[^] to achieve the same result.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Richard-
Yes! I'm needed to execute the ping command that rins in the command prompt from the IP addy I input into text box 1. I also want the out put of this to be displayed in a multiline text box.
Been all over searching and finding I'm getting more confused then I'm getting answers.
Thank you so much for the help!
-chris
|
|
|
|
|
Member 10570421 wrote: How can one enter an IP addy into a text box and tell DOS to Ping that IP addy and display that result in a text box? Look at Process.Start[^].
Member 10570421 wrote: Things discovered in this project could really be helpful to others. That's why there's the example on MSDN.
Adding the textboxes to get the params for the command should not be that hard
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
You're not doing anything in DOS. DOS has been dead for a long time now. What you're talking about is a command prompt which provides an interface that LOOKS like DOS and behaves somewhat like it.
The type of application you're talking about is a Windows Forms application, that has nothing to do with "DOS". You don't need to execute PING on a command prompt at all. Ping functionality can be found in the My namespace, under My.Computer.Network.Ping(...) . You don't need to shell out to the command-line version of PING at all.
My.Computer.Network.Ping()[^] docs.
|
|
|
|
|
Hi everybody, I had a big problem in my code using timer in DataGridView. When I load my program and starting navigate automatically using timer in DatagridView it doesn't no problem. Then, a second time around I refresh my datagridview to start again the timer. My Timer doesn't work as what it did when i first load my program to run my timer in datagridview. Any idea how to fix my problem.
I have the following code.
Private Sub Timer3_Tick(sender As Object, e As EventArgs) Handles Timer3.Tick
Dim name As String
Dim number As String
If i < TblContactsDataGridView.Rows.Count - 1 Then
Me.TblContactsBindingSource.MoveNext()
i = i + 1
TblContactsDataGridView.Rows(i - 1).DefaultCellStyle.BackColor = Color.White
TblContactsDataGridView.Rows(i).DefaultCellStyle.BackColor = Color.Blue
name = Me.TblContactsDataGridView.Rows(i).Cells(0).Value.ToString()
number = Me.TblContactsDataGridView.Rows(i).Cells(1).Value.ToString()
Me.TblContactsDataGridView.ClearSelection()
Me.TblContactsDataGridView.Rows(i).DefaultCellStyle.BackColor = Color.LimeGreen
Try
If objclsSMS.sendMsg(Me.port, number, txtMessage.Text) Then
Me.lblStatus.Text = "Message has sent successfully"
Me.lblStatus.Text = "Failed to send message"
End If
Catch ex As Exception
End Try
Else
Dim a As Integer
a = Me.TblContactsBindingSource.Count()
lblStatus.Text = "Message has sent successfully to " & a & " contacts"
Me.DbSMSDataSet.Clear()
End If
End sub
Thanks in advance.
|
|
|
|
|
Joannou H. Fegarido wrote: Then, a second time around I refresh my datagridview to start again the timer.
My Timer doesn't work as what it did when i first load my program to run my timer in datagridview. Any idea how to fix my problem.
What does "does not work" mean? Does it throw an exception? Does it fail silently? Does it compile?
It sounds like there's a difference in initializing (first run), and restarting (second run), probably due to some variable that's not reset. We can't see from the code whether that's the case, since only the code is shown that is run when the timer executes.
..and one could guess that things go bad as soon as "objclsSMS.sendMsg" takes more than the timers' interval. I see that it's called "timer3" - are there more timers in that form? You should consider moving it to a background-thread and updating the UI when the work is done.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Thank you for the quick response in my problem, I appreciate your response. I do not know how to fix it. I'm stock in this problem. Theres no problem on objclsSMS.sendMsg class.. I already tried datagridview and timer only to automatically navigate the record when i click the button. So, when I've done I refresh again the datagridview so that the cursor will be in the first row. The problem is, when i click the button to start again to navigate my record using timer it doesn't happen. Rows nothing navigate automatically.
|
|
|
|
|
Joannou H. Fegarido wrote: I do not know how to fix it. There's usually multiple ways; we will have to find one.
Private Sub Timer3_Tick(sender As Object, e As EventArgs) Handles Timer3.Tick
Dim name As String
Dim number As String
If i < TblContactsDataGridView.Rows.Count - 1 Then Where is i declared? Why is it not reset?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Thanks, I think that was the problem. But i do not know how to fix it, please help me to fix. Any help would be appreciated.
|
|
|
|
|
Try something like below; there'll probably be a field with the same name - that needs to be removed.
Private Sub Timer3_Tick(sender As Object, e As EventArgs) Handles Timer3.Tick
Dim name As String
Dim number As String
Dim i As Integer = 0
If i < TblContactsDataGridView.Rows.Count - 1 Then
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Thank you so much for your great help sir. I really appreciate it. I already fixed the problem, the only problem is the i because it doesn't reset to 0 once it done to navigate in datagrid. So in else statement i put i=0 and timer3.stop.
looks like this.
Timer3.Stop()
i = 0
frmStatus.ShowDialog()
Wonderful...
|
|
|
|