|
You need to enclose the path in quotes. VBScript needs these to be escaped properly as double quotes. So the final line would be
dllreg.run "regsvr32 /u ""C:\Program Files (x86)\histori.dll"""
Either way, I'm surprised that setting dllreg to a string worked. Normally CreateObject is used
|
|
|
|
|
Hi,
I wrote code as
Public Function UploadData(ByVal UDs As DataSet) As Long
Dim SkipRecCnt As Long = 0
For i As Integer = 0 To UDs.Tables(0).Rows.Count - 1
Try
SQLCmd.CommandText = UDs.Tables(0).Rows(i)(0).ToString()
SQLCmd.ExecuteNonQuery()
UDs.Tables(0).Rows(i)(1) = "1"
UDs.AcceptChanges()
Dim builder As OleDb.OleDbCommandBuilder = New OleDb.OleDbCommandBuilder(AccDa)
builder.GetUpdateCommand()
AccDa.Update(UDs)
Catch ex As Exception
SkipRecCnt = SkipRecCnt + 1
End Try
Next
At line builder.GetUpdateCommand() it is giving following error
Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information.
Please help me out.
|
|
|
|
|
You gave the CommandText property the value of a cell in a table instead of giving it a legal SQL query, that also, BTW, returns the primary key column of the table your SELECT statement is querying. The SqlCommandBuilder won't work with a query that returns data from multiple tables, nor will it work with a table that has no primary key.
|
|
|
|
|
I have two forms in my application.On form1 there is datagridview -dg1 which is filled with a dataset-ds1.
On form2 I have a some code ,which after fulfilling certain conditions updates the database table which is contained in ds1.
When this is done I want to refresh datagridview-dg1 and show the updated table.
Both the forms are already open and I have to update them.
Form2
Public Event refreshdg1(ByVal st As String)
Private Sub
.......Some condition -->True then
....... Update database table
'I tried three ways here
1- Raiseevent refreshdg1(s1)
2-
Dim StrCon As String
Dim conn As SqlConnection
StrCon = ConfigurationManager.AppSettings("StrCon")
conn = New SqlConnection(StrCon)
conn.Open()
Dim ds As New SqlDataAdapter("Select * from Tag_History where Tag_ID = '" + s1 + "' ", conn)
Dim commandBuilder As New SqlCommandBuilder(listadapter)
Dim table As New DataTable()
table.Locale = System.Globalization.CultureInfo.InvariantCulture
listadapter.Fill(table)
Form1.dg1.DataSource = table
conn.Close()
3- Form1.refreshdg(s1)
End sub
Form1:
Addhandler Form2.(I cant refreshdg1 here)
Private Sub refreshdg(ByVal s As String)
Dim f As New Parking_control
AddHandler f.refreshdg1, AddressOf refreshdg
Dim StrCon As String
Dim conn As SqlConnection
StrCon = ConfigurationManager.AppSettings("StrCon")
conn = New SqlConnection(StrCon)
conn.Open()
Dim person As String
person = s
Dim ds1 As New SqlDataAdapter("Select * from Tag_History where Name = '" + person + "' ", conn)
Dim commandBuilder As New SqlCommandBuilder(ds1)
Dim table As New DataTable()
table.Locale = System.Globalization.CultureInfo.InvariantCulture
listadapter1.Fill(table)
table.Columns(0).ColumnName = "Tag ID"
table.Columns(1).ColumnName = "Date Time"
table.Columns(3).ColumnName = "Tag Status"
dg1.DataSource = table
conn.Close()
End Sub
|
|
|
|
|
You can use Eventheandler for Refresing DataGrid.
If you can think then I Can.
|
|
|
|
|
how..what do you mean..haven't i used that already?
|
|
|
|
|
He means set up a delegate that is called in form2 and is hooked to a method in form1
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
Wow - what horrible code. Also, depending on where 's' comes from, odds are good that I could erase your database just by using the search functionality.
The answer to your original question is delegates, but I'd say you have a long way to go in general before you can write code anyone would want to run, let alone pay for.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
Why are you being rude? Please remove your comment.
|
|
|
|
|
This is a case where you do not need an event. Events are good when one or more objects need to react to another object's behavior. Here one form is telling the other form to update. Therefore, you just need a simple method call. Event handling just complicates the communication between the two forms (objects).
Remove all event handling code, such as the Public Event , AddHandler , and RaiseEvent statements. Just call Form1.refreshdg(s1) as you did in Item #3.
I usually use RefreshUI as the standard entry point for my forms. If needed, I will add RefreshData , RefreshButtonState , and so on.
|
|
|
|
|
|
dear all
i would like to create an application: i wanna use 2 options buttons to control 2 frames, when i click option1, the frame1 will be activitaed, otherwise frame2 will be activitated. thanks a lot
how to control by 2 options' button. thanks
|
|
|
|
|
You have to be a bit more specific.
What kind of application is it? Is it a windows form application or a web application? What do you mean with a "options button"? What kind of frames are you talking about, and what should happen when they are activated?
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
What part is confusing you ? What do you mean by 'frames' ? You would have event handlers for your buttons and these would activate/show your 'frames'
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
Button1_on click etc
Frame1.show
Button2_on click etc
Frame2.show
------------------------------------
"I am always serious about what I do, not necessarily about how I do it."
Tom Baker
|
|
|
|
|
Hi all,
I have developed an window base application using vb.net and mssql 2008 express.It is working fine.
now i have installed it on my client's machines, But i am facing a problem. my client has two pc One at home and another at his office. One person working on the home pc and another on office pc at the same time.
my client wants to synchronize data when ever he wants by using Internet.
In response i have an idea in my mind as following
step 1 Take backup of one pc(say office pc) and send it to second pc(say home pc)
step 2 ask to person working at home pc to download backcopy and restore it on the his pc.
step 3 after updating home pc he also take backup of the home pc and same send it to office pc.
step 4 at office the person working download the backupcopy and restore the same on his pc.
but fear it takes long time and usage of internet.
Kindly suggest me the best way in details.
Thanks
Rm
rmshah
Developer
|
|
|
|
|
Well, thats not going to work as you overwrite the database on the home pc with the one from the office pc, so you lose the work done on the home pc.
One way is to add columns to your tables with the update time and action (add/change/delete) and use that those determine which records to update on the other system.
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
Okay, I am trying to automate the download of data from a web based database. I can automate the login in and getting to the right pages, but when I try to download the database I get a "File Download - Security Warning" popup message box. I have tried to use AppActivate to put the focus on the message box and then send the keys to click the save button on the popup message box. This doesn't work correctly. The AppActivate seems to activate the message box, but when I send the keys it sends to the visual studio menus. Could someone point me in the direction of an article or explain to me how to make this work correctly? I have used Goggle (where I got the code I am using) but I can't find anything that says different than what I am doing. I am not using this on a windows form it is an aspx page.
(Sample code that I am using)
Dim objShell
objShell = CreateObject("WScript.Shell")
AppActivate("File Download - Security Warning")
objShell.SendKeys.Send("%S")
objShell.SendKeys.Send("{Enter}")
Thanks in advance for any assistance with this problem.
If you can’t have fun at work, then why go to work?
|
|
|
|
|
SendKeys is notoriously unreliable. Since Windows is a shared envrionment, the focus can move from one control or window to another at any time and for any reason. The focus can move between the AppActivate statement and your call to SendKeys.
You'll have to use a more reliable method that sends key strokes directly to a window's message pump instead. You'll use the Win32 API functions FindWindow and SendMessage at the very least.
|
|
|
|
|
Do you know of a good website or article that explains how to do this? I have been working on this about a week and it is the hold up of me finishing this project. I will try googling it, but if you know of a good resource that would be appreciated.
Thanks
If you can’t have fun at work, then why go to work?
|
|
|
|
|
Thanks for the information. I found some code but I'm not quite understanding it. Below is the snippet I am using:
Dim docName = FindWindow(vbNullString, "File Download - Security Warning")
Const BM_CLICK As Integer = &H102
SendMessage(docName, BM_CLICK, 0, 0)
I have the following two questions:
What does the &H102 stand for?
And where or how do I tell it that I want the saved button clicked? The save button does have the short cut key of Alt-S that I can send, but I don't understand where that information goes.
Thank you for any assistance with this issue.
If you can’t have fun at work, then why go to work?
|
|
|
|
|
not having a chance to use vb in 10 years, (the beginning of vb4 was my last time before this) i seem a little confused on quite alot of vb'ing. it's catching up quickly though.. )
Here's my problem question:
i want the listbox to load from a folder show only the file name, without the path and extension, and how to click the file to show the file content in a textbox and the file name in another text box.
please only reply if you have simple answers and not a whole bunch of crazy code no one like me understands until the desktop icons are gone... not funny.. ,
thanx,
trujade
.:trujade:.
|
|
|
|
|
System.IO.Directory.GetFiles, System.IO.Path.GetFileNameWithoutExtension, are the main methods you need to get file names for a folder, without extensions
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
here is the solution to my question.
new project, 2 textboxes, 1 button, 1 listbox.
Public Class Form1
'-- create a string for the folder path
Dim myDirectory As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Button1.Text = "select folder"
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim fbd As New FolderBrowserDialog
fbd.RootFolder = Environment.SpecialFolder.Desktop
If fbd.ShowDialog = DialogResult.OK Then
'-- set the directory for use to load each file from the folder
myDirectory = fbd.SelectedPath
End If
'-- load files in listbox, filenames only
For Each file As String In My.Computer.FileSystem.GetFiles _
(myDirectory, FileIO.SearchOption.SearchTopLevelOnly, "*.txt")
ListBox1.Items.Add(System.IO.Path.GetFileNameWithoutExtension(file))
Next
ListBox1.Select()
End Sub
Private Sub ListBox1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.DoubleClick
Try
Dim myFile As String = myDirectory & "\" & ListBox1.SelectedItem & ".txt"
'-- file content
TextBox1.Text = IO.File.ReadAllText(myFile)
'-- file name w/extension
TextBox2.Text = IO.Path.GetFileName(myFile)
Catch ex As Exception
End Try
End Sub
End Class
|
|
|
|
|
Hi
I am not sure whether this is the right forum to ask this question, but I am using the web browser control in Visual Studio 2008 to create my own browser. Firstly, dragging the control onto a form, and run it I can access all of my web pages, so no problem there, but I have a few questions that I need to find answers to:
1) As the web browser control is an instance of IE, then if Java Script is disabled in Internet Explorer, would it be disabled in my browser? If not, is there a way of ensuring programmatically disable it in my explorer as this is what I want? Likewise, I would like to ensure that Active X is enabled in my browser?
2) My second question is that my web application will not have an address because I want to hide this away for security reasons. Rather re-create my web browser to change the URL if the web pages move to a different server, is there away I can use an INI or some text file which will hold this information if such a thing were to happen - can someone help me on this?
3) I have used IsWebBrowserContextMenuEnabled = False to switch off right clicks in the browser - is there away to switch off key press commands, such as ctrl P, print screen in a bespoke web browser?
I hope some one can help!
Thanks
|
|
|
|