|
Hi,
I am using the following script to write key and values into registry using vbscript.
this is my code
strComputer = "."Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")keyPath = "*\shellex\ContextMenuHandlers\WWBuildShell64Ext"Return = oReg.CreateKey HKEY_CLASSES_ROOT ,keyPath If (Return = 0) And (Err.Number = 0) Then Wscript.Echo "HKEY_LOCAL_MACHINE\Software\MyKey\MySubKey created"Else Wscript.Echo "CreateKey failed. Error = " & Err.NumberEnd If
It is retuning 6. What does it mean? how to correct it?
Please help me.
Thanks
|
|
|
|
|
About 10 seconds worth of Googling reveals that the return code 6 means that a handle is invalid. That would probably mean that you didn't define a value for HKEY_CLASSES_ROOT, which would put it's default value to 0. I don't think that's valid, so another Google for "VBScript HKEY_CLASSES_ROOT" says the declaration for it should be:
Const HKEY_CLASSES_ROOT= &H80000000
|
|
|
|
|
Hi,
I have a little problem. I'm trying to connect to a SQL Server Compact database that I have created called RunningDB.sdf. I'm having real problems with the connection string. I have search the internet and used numerous connection strings and still I Get the same error which is
SQL Exception
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
Is there a problem with my sql server or is it just my connection string. Heres the connection string that Im using
Dim cn As New SqlConnection("Persist Security Info=True;Initial Catalog=RunningDB;Data Source=(local);Packet Size=4096;)
cn.Open()
Thanks for your time
|
|
|
|
|
carrigart wrote: Is there a problem with my sql server or is it just my connection string. Heres the connection string that Im using
That looks like you are trying to connect to a full SQL Server.
Have a look at ConnectionStrings.com[^] for some examples of what you should be doing.
|
|
|
|
|
Hello Carrigart,
Heres a link to some questions and answers to creating an SQL Compact Database (it includes connection strings).
Note the last message on the thread where I post the code I gleaned from the responses and it works fine for me now.
Hope followong helps:
1) Cut and paste the following link into your browser to get to it.
http://www.tek-tips.com/viewthread.cfm?qid=1458923&page=1[^]
2) Connection string example:
Protected Const SQLDBfullfilename As String = "C:\Users\KGM\Documents\Visual Studio 2008\Projects\RPMS_2008\RPMSDAL\myDB_2008a.sdf"
Protected Const SqlCeConnectionString As String = "Data Source='" & SQLDBfullfilename & "'; LCID=1033;Password='sa'; Encrypt = TRUE"
Oh and Don't forget to add a reference to System.Dat.SqlServerCE [Compact Database v3.5 which comes with SQL2008] in your project.
cheers
kmalone
When in doubt chuck it out!
|
|
|
|
|
Thanks for your reply,
After much head scratching I figured out that I was trying to connect to a SQL Server Compact db when in fact I should have been trying to connect to a sql server 2005 db. A good noobie mistake I hope. With that I have hit another stumbling block. I have opened my connection and I have setup up my DataAdapter and Im trying to fill my dataset and follows
da = New SqlDataAdapter("SELECT * FROM Testing", conn)
da.Fill(ds)
Testing is the name of a table in My Database, conn is my connection that has been opened. When I run the code I get a runtime error saying that
System.Data.SqlClient.SqlException was unhandled
Class=16
ErrorCode=-2146232060
LineNumber=1
Message="Invalid object name 'Testing'."
I dont know what is wrong. Im able to open a populate a dataset when I use Access but I have hit wall after wall with SQL Server
|
|
|
|
|
Hi All,
I have encountered this strange behaviour with Form.Show/ShowDialog. I am converting a VB.NET windows application to class library. For some reason VB developers like to call Show()/ShowDialog() directly on the class without instantiating it first. And it works fine in a Windows application project even though these methods are not static/shared.
But as as soon as I convert it to a Class Library project, I get zillions of "Reference to non-shared memeber requres an object referece" errors. It is complaining that I haven't instantiated the Form first. But it worked fine in the Windows Application project! So what am I missing? I really don't want to go through zillions of lines of code and instantiate each one of them.
If anyone has an answer to this, I will greatly appreciate it and will make payment in lots of good wishes.
Bolt.
|
|
|
|
|
Surely you won't be able to call Form.Show() from a class library anyway?
|
|
|
|
|
Hello
I have a problem with a bindingsource.
I have a dataset of values bind to text and combo boxes on the form for the user to edit.
The combo boxes are bind to another dataset. I need to filter the lookup values in the combo boxes. I use the filter on the bindingsource of the combo boxes. This filter needs to be dynamic as certain fields filter another…
My filter looks something like
BS.Filter = "Status='1'OR Field = '" & value
Now the data filter correct and everything… But when I want to exit the field I check for the following
If ds.table.GetChanges IsNot Nothing Then
PromtUnsavedChanges()
End If
The use is prompted to save the data even if they did not change any fields. If I remove the filter everything works fine.
I endedit in debug mode before and after the filter is assigned and it is after the filter is assigned that the problem happens…
Does anyone know why this is happening and how to fix it. It will be highly appreciated. I have many problems with this.
Thanks,
Christiaan
|
|
|
|
|
Using debugger, see what ds.table.GetChanges returns. If it isn't Nothing you should get a datatable containing all the modifications. When examining it's rows, perhaps you would get a hint what rows are interpreted as changed or why.
|
|
|
|
|
Goood Morning
Thanks for your reply. I did check that. And the values before (original) and (proposed) are the same.
I think what happens (might be wrong) when the filter is applied the value gets update by the same value again.
Do you know if there is away to check which value changed (that it is complaining about) in the row?
Thanks,
Christiaan
|
|
|
|
|
Seems that we're on the same timezone
The indexer in datarow has an overload which I think you could use. See: DataRow.Item Property (DataColumn, DataRowVersion)[^]. Using that, you can compare the current value of a column in a row and the original value which you have in the DataRow.
|
|
|
|
|
Hi Everyone
Sorry for the delay but I was on leave for 2 days.
For some reason when I apply the filter on the bindingsource it changes my data. I did look at all the original / current / proposed values and they are all the same.... Don't know why this happens.
The work around that I did was, after I apply the filter, I Accept the changes.
Thanks for your help...
Christaan
|
|
|
|
|
How to copy the content of an array(40) to the clipboard?
So when you paste this content to the notepad you get 40 lines of tekst.
|
|
|
|
|
When you put the data on the clipboard, you put it ono using only a Text format. Convert your array to a String, however you want it formatted, then just call Clipboard.SetText(myString, TextDataFormat.Text)
|
|
|
|
|
I am making a new screen in an existing app. I am wanting to show relationships between clients and guardians in our database. I would like to do this with something like a control that when you hit the + sign it opens up and shows the next records. Does anybody know what the name of this control is? Any suggestions and/or ideas on this would be much appreciated.
Humble Programmer
|
|
|
|
|
Do you mean trapping the + keypress? I don't understand which 'control' you are referring to, do you mean in a treeview?
|
|
|
|
|
I am not referring to trapping the key press that is what the control looks like treeview sounds like what it might be called.
Humble Programmer
|
|
|
|
|
well there you go, treeview is what you where looking for. But it might be messy to show relationships, I would look into a charting control.
|
|
|
|
|
Do you have any suggestions.
Humble Programmer
|
|
|
|
|
1[^]
2[^]
Best of luck in your search
|
|
|
|
|
Thank you very much for your time.
Humble Programmer
|
|
|
|
|
<pre>
Here is a function to populate any combobox with data from a table column.This style wld work for any database. I prefer to use oracle in this instance.
</pre>
<pre>
You first have to create the function in a module or class
and call it from anywhere in your project with the required parameters
</pre>
<code>
'For instance, drop a combobox(combobox1) and a button(button1) and under the button add
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
'when calling from a class
'className.populateAnyCombo(comboboxName,"sql statment", _
'column name, connection string)
'---call function from a module----
PopulateAnyCombo(combobox1,"SQL(eg Select Column_Name from Table_Name)", _
"column_name", connectionString)
End Sub
'----------Place in a module or class----------
Public Function PopulateAnyCombo(ByVal cBox As ComboBox, ByVal strSQL _
As String, ByVal tableColumn As String,ByVal connString As String ) As String()
Dim array(0) As String
Dim cnt As Integer = 0
Dim conn As New OracleConnection
conn.ConnectionString = connString
Try
conn.Open()
Catch ex As Exception
MessageBox.Show(ex.Message, "Error")
MsgBox("Failed conection to Oracle" & ex.Message)
Return array
End Try
Dim cmd As New OracleCommand
With cmd
.CommandText = strSQL
.CommandType = CommandType.Text
.Connection = conn
End With
'data reader to store recordsets retrieved
Dim dr As OracleDataReader
'Reading an populating records in array
'ReDim preserve increases the array size and preserve old members
Try
dr = cmd.ExecuteReader
While dr.Read
ReDim Preserve array(cnt)
array(cnt) = dr.Item(tableColumn)
cnt = cnt + 1
End While
cBox.Items.Clear()
cBox.Items.AddRange(array)
Return array
Catch ex As Exception
MessageBox.Show(ex.Message, "Error")
Dim a(0) As String
a(0) = 0
Return a
Finally
conn.Close()
conn.Dispose()
End Try
End Function
'-----------------place in a module or class-------------
</code>
<pre>
Would be glad to know if i helped solve a problem
Criticisms to this snippet are welcomed
nan492001@yahoo.com
</pre>
|
|
|
|
|
Please learn how to format a message correctly. The <pre> tags are meant to enclose blocks of code (multiple lines of code) not message text. The <code> tags are meant to enclose small sections of code that are meant to be read in-line with the sentence.
This is how your message should look:
Here is a function to populate any combobox with data from a table column.This style wld work for any database. I prefer to use oracle in this instance.
You first have to create the function in a module or class
and call it from anywhere in your project with the required parameters
For instance, drop a combobox(combobox1) and a button(button1) and under the button add
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
'when calling from a class
'className.populateAnyCombo(comboboxName,"sql statment", _
'column name, connection string)
'---call function from a module----
PopulateAnyCombo(combobox1,"SQL(eg Select Column_Name from Table_Name)", _
"column_name", connectionString)
End Sub
'----------Place in a module or class----------
Public Function PopulateAnyCombo(ByVal cBox As ComboBox, ByVal strSQL _
As String, ByVal tableColumn As String,ByVal connString As String ) As String()
Dim array(0) As String
Dim cnt As Integer = 0
Dim conn As New OracleConnection
conn.ConnectionString = connString
Try
conn.Open()
Catch ex As Exception
MessageBox.Show(ex.Message, "Error")
MsgBox("Failed conection to Oracle" & ex.Message)
Return array
End Try
Dim cmd As New OracleCommand
With cmd
.CommandText = strSQL
.CommandType = CommandType.Text
.Connection = conn
End With
'data reader to store recordsets retrieved
Dim dr As OracleDataReader
'Reading an populating records in array
'ReDim preserve increases the array size and preserve old members
Try
dr = cmd.ExecuteReader
While dr.Read
ReDim Preserve array(cnt)
array(cnt) = dr.Item(tableColumn)
cnt = cnt + 1
End While
cBox.Items.Clear()
cBox.Items.AddRange(array)
Return array
Catch ex As Exception
MessageBox.Show(ex.Message, "Error")
Dim a(0) As String
a(0) = 0
Return a
Finally
conn.Close()
conn.Dispose()
End Try
End Function
'-----------------place in a module or class------------- Would be glad to know if i helped solve a problem
Criticisms to this snippet are welcomed
nan492001@yahoo.com That being said, why is this a forum post? What is your question here?
Scott Dorman Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA
[ Blog][ Articles][ Forum Guidelines] Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
|
|
|
|
|
Personally, I don't have a lot of use for this code, however this is a VB forum. Do topics only have to be questions? The discussion is VB specific and isn't one of the common repeated questions topics.
I thought it was cool that nan49 attempted to post some utility code that he thought would be beneficial to other members (vs. creating a full blown guide\tutorial) - although the formatting was hosed.
My .02S
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|