|
Hi!
Asuming that you are using MS SQL Server
You need to avoid primary key and null value violations on your own
Use
Insert Into [Source Database Name].[Object Owner Name].[Destination Table]
From
[Destination Database Name].[Object Owner Name].[Source Table Name]
Example:
Insert Into NorthwindBackup.dbo.Products
Select * from NorthWind.dbo.Products
Or
Insert Into NorthwindBackup..Products
Select [Fields List] from Northwind..Products --name, data type and sequence of the fields must be the same as in destination table
--you may include your WHERE clause here
|
|
|
|
|
Hey All,
In my application I have Print Feature
Now What I want that as the User Click on Button Print
I have shown Printer Dialog Box to Select the Printer
Now AS user selects the printer I want to know about the Selected printer
is a :
Laser Printer
Dot Matrix
Or Label Printer etc
After determining the printer I have perform a certain task
My Problem is How to determine the printer type (Laser etc.) after selection from the user????
Hope My Question is Clear
Wating for all early replies
Thanks in advance
Hema Chaudhry
|
|
|
|
|
The InstalledPrinters collection has an IsPlotter property; but, I don't think printer type other than plotter is readily available. If anyone knows better, I'd like the answer to this one also.
Do or not do. There is no try.
|
|
|
|
|
|
Thanks for the Precise answer,
But I have tried this earlier also; I gives an exception In the following line , I can;t understand why is this giving this type of exception (System.NullReference)
Dim intMarking As Integer = CType(mo("MarkingTechnology").ToString
can U get the problem
If Yes Plaz resolve this
Thanks a lot
Hema Chaudhry
|
|
|
|
|
I am connecting to a database. now i trying to get the information about database like Backup info, database size, Owner, Creation date etc.
How can i get this information? Any help will be appreciated.
|
|
|
|
|
I work with SQL Server, so I don't know if this helps with other DBMS's, but have you tried looking in the Master database, system tables? There is a wealth of information about the databases in there.
Roy.
|
|
|
|
|
I have a very simple xml file
<RegistrationSettings>
<SMTPServer>mail.not-real.com.au</SMTPServer>
<FromAddress>from@not-real.com.au</FromAddress>
<HostName>Jason</HostName>
<HostAddress>jason@not-real.com.au</HostAddress>
</RegistrationSettings>
and I want to read a single value out of that, for example: <HostName>
I don't know how to do this
This is the code I have at the moment (inItemName = "HostName")
Try
xmlobjReader = New XmlTextReader(_XMLPath)
xmlobjReader.WhitespaceHandling = WhitespaceHandling.None
While xmlobjReader.Read
If xmlobjReader.Name.ToLower = inItemName.ToLower Then
itemValue = xmlobjReader.Value
End If
End While
Catch ex As Exception
itemValue = ""
Finally
If Not xmlobjReader Is Nothing Then
xmlobjReader.Close()
End If
End Try
At the end of this code itemValue == ""
I know this should be easy, but I can't see what I am doing wrong.
Thanks for any help
/jason
|
|
|
|
|
Jason,
The parsing of the XML was not quite correct. Try this amended code.
Try
xmlobjReader = New XmlTextReader(_XMLPath)
xmlobjReader.WhitespaceHandling = WhitespaceHandling.None
xmlobjReader.MoveToContent()
Dim isHostName As Boolean
Do While xmlobjReader.Read
Select Case xmlobjReader.NodeType
Case XmlNodeType.Element
isHostName = (rdrXML.Name.ToUpper = "HOSTNAME")
Case (XmlNodeType.Text And isHostName)
itemValue = xmlobjReader.Value
End Select
Loop
Catch ex As Exception
itemValue = ""
Finally
If Not xmlobjReader Is Nothing Then
xmlobjReader.Close()
End If
End Try
Step through the code in the debugger and inspect the various variables to see what's happening.
...Steve
"Give a man a fish and you've fed him for a day. Teach him how to fish and you've fed him for life." (Translation: I'll show you the way, but not write the code for you.) I read that somewhere once
|
|
|
|
|
Thanks for your help Steve, but in the end I decided not to go that way. I decided it was too slow to loop throw each element in the XML and check it's type etc
instead I have used a dataset
Public Sub New(ByVal inXMLFilePath As String)
_XMLPath = inXMLFilePath
_dsRegistrationValues = New DataSet(_DATASET_TABLE_NAME)
_dsRegistrationValues.ReadXml(_XMLPath)
End Sub
<br><br>
Public Function ReadItem(ByVal inItemName As String) As String
Dim returnSettingValue As String
returnSettingValue = _dsRegistrationValues.Tables(0).Rows(0).Item(inItemName)
Return returnSettingValue
End Function
I got the idea from this article, if you are interested
http://www.codeproject.com/vb/net/ConfigOpt.asp[^]
/jason
|
|
|
|
|
That's a neat solution Jason. Thanks for the link. I'll check it out.
...Steve
"Give a man a fish and you've fed him for a day. Teach him how to fish and you've fed him for life." (Translation: I'll show you the way, but not write the code for you.) I read that somewhere once
|
|
|
|
|
How can you import 2003 VB.net codes or application into VB.net 2005?
Dmaster
|
|
|
|
|
Visual Studio 2005 includes a VS 2003 conversion tool. It will automatically update the VS 2003 project to VS 2005 when you open it.
...Steve
"Give a man a fish and you've fed him for a day. Teach him how to fish and you've fed him for life." (Translation: I'll show you the way, but not write the code for you.) I read that somewhere once
|
|
|
|
|
|
Hello everybody. I have a weird error message coming up every time i try to use the Update command with a access database. The message says that there is a syntax error with the SQL command. I search the Internet and the syntax of my command seems to be right.
Here is the code:
============================================================================
Public Sub updateRecord(ByVal entryToChange As String, ByVal oldString As String, ByVal newString As String)
Dim SQLString As String
Dim strConnection As String = OleDbConnection1.ConnectionString
Dim objTransaction As OleDbTransaction
Dim connect As New OleDbConnection(strConnection)
SQLString = "UPDATE tblIns SET " & entryToChange & " = '" & newString & "' WHERE Ins = '" & oldString & "'"
Dim cmd As New OleDbCommand(SQLString, connect)
connect.Open()
Try
cmd.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
connect.Close()
connect.Dispose()
Me.Close()
End Sub
============================================================================
I have a value that changes (newString) and a value that i know it's the same (oldString). entryToChange is the entry that i'm trying to change (eg Date, or FirstName etc) So basicly i'm trying to change a value of a record where the oldString stays the same. But i get the error "Syntax error with UPDATE command". What is going on?
And is there a way to update a record when the entry that is changing is not the same all the time? Meaning in one record the first name may change and all other entries (eg last name, address etc) stays the same, in the other the last name may change and the rest of the entries will stay the same. In VB6 i used to use something like:
==============================================================
DatIns.Recordset.Edit
DatIns.Recordset.Fields("Date").Value = lbldate.Caption
==============================================================
but in vb.NET i can't find something like this. Thank you for your help, and Merry Christmas to all.
Still trying to find the way
-- modified at 18:27 Tuesday 20th December, 2005
|
|
|
|
|
What is the value of SQLString when cmd.ExecuteNonQuery() executes?
-- modified at 8:41 Wednesday 21st December, 2005
|
|
|
|
|
The SQLString ends up looking like this:
SQLString = "UPDATE tblIns SET Date= '21/12/05' WHERE Job_Number = '0909090'
which looks like it's correct. But i still get an error message of "Syntax error". What am i doing wrong?
Still trying to find the way
|
|
|
|
|
Have you tried this? Assuming tblIns.date is a date field.
"UPDATE tblIns SET Date= cdate('21/12/05') WHERE Job_Number = '0909090'
|
|
|
|
|
I have the following code in a C++ shell extension from a user selecting files right click. I have the list of files and can iterate them through a progress dialog, but how do I send them to and receive them in a list box VB forms application? THanks.
HRESULT CDllRegShlExt::InvokeCommand ( LPCMINVOKECOMMANDINFO pCmdInfo )
{
// If lpVerb really points to a string, ignore this function call and bail out.
if ( 0 != HIWORD( pInfo->lpVerb ))
return E_INVALIDARG;
// Check that lpVerb is one of our commands (0 or 1)
switch ( LOWORD( pInfo->lpVerb ))
{
case 0:
case 1:
{
CProgressDlg dlg ( &m_lsFiles, pInfo );
dlg.DoModal();
return S_OK;
}
break;
default:
return E_INVALIDARG;
break;
}
}
|
|
|
|
|
Is this accomplished through the clipboard?
|
|
|
|
|
doesnt make sense. How does the application know that there is data on the clipboard to start the retrieval? Can the shell send the file list directly to the running app? How would the app be notified?
|
|
|
|
|
hi friends, can tell me how to Retrieve email attchment from POP3 server using vb.net.
Thank you
ravincarlos@yahoo.com
Share ur code & happiness on the net.
|
|
|
|
|
Hi everyone,
Was wondering if anyone has any insight into how to set the selected index of a comobox to -1 without firing the event twice. I am using a method/procedure/function that gets called when the combobox needs to set its selected index = -1. I have tried
Public Sub emptyIndex(ByVal e As System.EventArgs)
Me.SelectedIndex = -1
Call Me.OnSelectedIndexChanged(e)
End Sub
AND
Public Sub emptyIndex(ByVal e As System.EventArgs)
Me.SelectedIndex = -1
Me.SelectedIndex = -1
End Sub
AND
Public Sub emptyIndex(ByVal e As System.EventArgs)
Me.SelectedIndex = 0
Me.SelectedIndex = -1
End Sub
The first bit of code seems to fire the selected index changed twice. The second event doesn't fire at all, and the last event seems to fire the selectedindexchanged event 2 times. Hope to hear from anyone out there soon. Thank you and merry xmas
eatwork
-- modified at 13:20 Friday 23rd December, 2005
Not too sure if that makes sense. I will try this again...
I have a custom combobox. I am trying to code the custom control to autocomplete as the user types characters into the combobox. If the user presses backspace/delete or enters typed a value that does not exist in the list, I want the combobox to set its selected index to -1 and raise the selected index changed event when this happens. I have found the autocomplete combobox on this website that handles the keydown, keypressed, keyup events, and then I call a function called autocomplete. This function checks to see if the text is "", or if the typed value is similar to a value within the combobox. if the text is "" or there is no matching value I call the functin empty index. This function, after doing some research on .net comboboxes, sets the selected index to -1 twice, because if you set it only once it resets the combobox index to 0 if the current index is not 0. If the selected index = -1 already, the event that the selected index has changed will not be raised, becase nothing has changed. I need to know when the user typed values change the selected index to -1 because it will raise an envent when used on my winFrm.
Code:
Public sub AutocompleteFunction()
If typedText = "" Then
iFoundIndex = -1
Else
iFoundIndex = Me.FindString(typedText)
End If
If iFoundIndex >= 0 Then
oFoundItem = Me.Items(iFoundIndex) 'stores found item in an object
sFoundText = Me.GetItemText(oFoundItem)
concatenatedText = sFoundText.Substring(typedText.Length)
Me.Text = typedText & concatenatedText
Me.SelectionStart = typedText.Length
Me.SelectionLength = concatenatedText.Length
If e.KeyCode = Keys.Enter Then
iFoundIndex = Me.FindStringExact(Me.Text)
Me.SelectedIndex = iFoundIndex
SendKeys.Send(vbTab)
e.Handled = True
End If
Else
Call Me.emptyIndex(e)
If IsNothing(typedText) Or typedText = "" Then
If Me.Text <> "" Then
Me.Text = ""
End If
Me.SelectionStart = 0
Else
Me.Text = typedText
Me.SelectionStart = typedText.Length
End If
End If
End sub
Public Sub emptyIndex(ByVal e As System.EventArgs)
Me.SelectedIndex = 0
Me.SelectedIndex = -1
'Call Me.OnSelectedIndexChanged(e)
End Sub
Setting the value to 0 first, will ensure that the SelectedIndexChanged event is fired. but it raises that event twice, and I only want it to raise the event once. Setting the index to -1, -1 doesn't raise the event at all. Desperately in need of advice. Thanks
-- modified at 15:25 Friday 23rd December, 2005
|
|
|
|
|
are u looking for this???
me.comboBox2.Items.IndexOf(-1);
If me.comboBox2.SelectedIndex = -1
MessageBox.Show("comboBox2 item is -1")
else
MessageBox.Show("None")
endif
|
|
|
|
|
Hi Albanian,
Thanks for the response. I tried your code, but realized that the me.comboBox2.Items.IndexOf(-1) returns the value of the combobox. I am searching for code that will change the selected index of the combobox to -1 and raising the selectedIndexChanged event if the index is not currently -1. Not too sure if that makes sense. I will try this again...
I have a custom combobox. I am trying to code the custom control to autocomplete as the user types characters into the combobox. If the user presses backspace/delete or enters typed a value that does not exist in the list, I want the combobox to set its selected index to -1 and raise the selected index changed event when this happens. I have found the autocomplete combobox on this website that handles the keydown, keypressed, keyup events, and then I call a function called autocomplete. This function checks to see if the text is "", or if the typed value is similar to a value within the combobox. if the text is "" or there is no matching value I call the functin empty index. This function, after doing some research on .net comboboxes, sets the selected index to -1 twice, because if you set it only once it resets the combobox index to 0 if the current index is not 0. If the selected index = -1 already, the event that the selected index has changed will not be raised, becase nothing has changed. I need to know when the user typed values change the selected index to -1 because it will raise an envent when used on my winFrm.
Code:
Public Sub emptyIndex(ByVal e As System.EventArgs)
Me.SelectedIndex = 0
Me.SelectedIndex = -1
'Call Me.OnSelectedIndexChanged(e)
End Sub
Setting the value to 0 first, will ensure that the SelectedIndexChanged event is fired. but it raises that event twice, and I only want it to raise the event once. Setting the index to -1, -1 doesn't raise the event at all. Desperately in need of advice. Thanks
eatwork
|
|
|
|