|
Chaps and Chapettes,
I am getting the following error in my wee data application: -
Cannot set column 'vcGraphicCode_GRA'. The value violates the MaxLength limit of this column.
The code does a pretty standard create a new row via a oRow = table.newrow() statement, then populates oRow.<list of="" columns=""> with a set of values (no nulls here btw). Then does a table.AddRow(oRow)...this is when I get the error.
The particular column in the error is a string of 5 characters (a SQL 2005 varchar(5) column). The value I place in there is for example "00152". The table I am inserting the row into is always empty (since the table is on a form for setting up new SKU items). The table is also pre-defined in an XSD file within my project.
Yes, the error informative is pretty straight forward. However, the maximum size of the field is 5 characters and the value I am attempting to place into it is exactly 5 characters in length.
I'm beginning to think that sticking with VFP, where this operation would be a straight INSERT on a remote view, would be easier!
Monkey
|
|
|
|
|
So there would be some length problem?
you did not try making the field a VARCHAR(6) or the data somewhat shorter, say "0152", did you?
you did not think about a terminating NULL character that also needs to be stored, just like C does?
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
Hi Luc
No, the string being returned is EXACTLY 5 chars in length. The column on SQL 2005 is a varchar(5). However things are not getting that far...
What is happening is that my 5 char string is being rejected, not by the row, but by the table in my dataset - which is in an XSD file based on my SQL 2005 schema. It seems strange since I am creating the row from the table (table.NewRow) AND I can put the data into the new row and look at it via debugger.
My problem occurs when I do a table.AddRow(Row) - THEN it complains that the data is too big.
If the string was too long, say 6 chars or more, then I would just expect truncation to occur...not an error.
Monkey
|
|
|
|
|
did you try with a string of length 4 or didn't you?
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
I have just tried...and yes, it still complains!!
|
|
|
|
|
Then I don't know.
I do know MySQL accepts ans correctly stores strings with n chars when VARCHAR(n) was specified, however it does issue a warning when you do this. I suspected your DataTable operation did not like the warning.
Something else must be wrong then.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
Luc
Without a shadow of a doubt yes!
The thing that is puzzling me is that the schema is garnered from the SQL 2005 schema.
The row behaves.
It's adding the row to the table in my dataset that causes the error...I've not even fired it back to the SQL 2005 database yet!!
I'll give up and do it in good old (and I MEAN old!) VFP!!
Cheers,
Monkey
|
|
|
|
|
i save my project form name in a table in database
i want read formname from database and save formname in a string variable
then use this command for this form
example: form1.enable=false
but i have a problem
because formname is a string and no have enable property
thank you
|
|
|
|
|
i think you could do this
make a new column in your database having boolean values which specify
whether the form is enabled or not, then do this:
if YourBooleanProp = True then
form1.enable = true
else
form1.enable = false
end if
or you can just do this:
form1.enable = YourBooleanProp
TheMrProgrammer
TheCalcMan: A no-mouse required Calculator supporting constant operator and visual effects
Try it once, its awesome!
Just 17.1 KB download.
No installation required. No dlls. Just unrar and go. And its a freeware.
http://www.hotlinkfiles.com/files/2642094_kjwr0/TheCalcMan.rar
|
|
|
|
|
Can anyone help me with making a very simple program in which I can draw a polygon and make it move left to right, or up and down?
I'm a beginner so I don't have sufficient knowledge about this but I know some of the basic. I have no problems in moving it side to side and up or down because I've done this type of program before. Only thing is I forgot how to start it by drawing a polygon. Please help. Just a sample code of a drawn polygon like square or something.
|
|
|
|
|
What have you tried ? Do you mean just drawing it, or the user draws it ? If the former, surely the MSDN will help you ?
You need to handle your forms paint event, then use the Graphics object in the event args to draw something. You call Invalidate() to force a paint event, so that if you move the object, it will redraw itself.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Hi all
I am developing an app which could be called by using a hot key.
i want to use a hook to do that unless there is another way of
doing (without using dlls other than microsofts as i don't want
to include any dlls in my app) it as i've heard that hooks degrade system performance.
i use setwindowshookex,callnexthookex, and unhookwindowshookex
i did a bit of googling and found microsift's eg of mouse hook
and tried to convert it in a keyboard hook but without success.
every time i run it
the msgbox comes to say "SetWindowsHookEx Failed"
here's the code:
Dim WH_KEYBOARD As Integer = 2
Shared hHook As Integer = 0
Public Delegate Function CallBack(ByVal nCode As Integer, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As Integer
Private hookproc As CallBack
<DllImport("User32.dll", CharSet:=CharSet.Auto, CallingConvention:=CallingConvention.StdCall)> _
Public Overloads Shared Function SetWindowsHookEx _
(ByVal idHook As Integer, ByVal HookProc As CallBack, _
ByVal hInstance As IntPtr, ByVal wParam As Integer) As Integer
End Function
<DllImport("User32.dll", CharSet:=CharSet.Auto, CallingConvention:=CallingConvention.StdCall)> _
Public Overloads Shared Function CallNextHookEx _
(ByVal idHook As Integer, ByVal nCode As Integer, _
ByVal wParam As IntPtr, ByVal lParam As IntPtr) As Integer
End Function
<DllImport("User32.dll", CharSet:=CharSet.Auto, CallingConvention:=CallingConvention.StdCall)> _
Public Overloads Shared Function UnhookWindowsHookEx _
(ByVal idHook As Integer) As Boolean
End Function
<StructLayout(LayoutKind.Sequential)> Public Structure KeyHookStruct
Public pt As Point
Public hwnd As Integer
Public wHitTestCode As Integer
Public dwExtraInfo As Integer
End Structure
Private Sub sethook()
If hHook.Equals(0) Then
hookproc = AddressOf KeyHookProc
hHook = SetWindowsHookEx(7, hookproc, IntPtr.Zero, System.Threading.Thread.CurrentThread.ManagedThreadId())
If hHook.Equals(0) Then
MsgBox("SetWindowsHookEx Failed")
Return
Else
'Button1.Text = "UnHook Windows Hook"
End If
Else
Dim ret As Boolean = UnhookWindowsHookEx(hHook)
If ret.Equals(False) Then
MsgBox("UnhookWindowsHookEx Failed")
Return
Else
hHook = 0
' Button1.Text = "Set Windows Hook"
Me.Text = "Mouse Hook"
End If
End If
End Sub
Public Shared Function KeyHookProc( _
ByVal nCode As Integer, _
ByVal wParam As IntPtr, _
ByVal lParam As IntPtr) As Integer
Dim MyKeyHookStruct As New KeyHookStruct()
If (nCode < 0) Then
Return CallNextHookEx(hHook, nCode, wParam, lParam)
End If
MyKeyHookStruct = CType(Marshal.PtrToStructure(lParam, MyKeyHookStruct.GetType()), KeyHookStruct)
Dim tempForm As Form
tempForm = Form.ActiveForm()
Dim strCaption As String
strCaption = "x = " & MyKeyHookStruct.pt.x & " y = " & MyKeyHookStruct.pt.y
tempForm.Text = strCaption
Return CallNextHookEx(hHook, nCode, wParam, lParam)
End Function
well, i am really at my wits end.
can you help me set the hook right?
i guess i'll have to change KeyHookProc's paramters.
TheMrProgrammer
|
|
|
|
|
hey Cristian,Luc,Dave and all other genius people
where are you?
i need your help!!
TheMrProgrammer
TheCalcMan: A no-mouse required Calculator supporting constant operator and visual effects
Try it once, its awesome!
Just 17.1 KB download.
No installation required. No dlls. Just unrar and go. And its a freeware.
http://www.hotlinkfiles.com/files/2642094_kjwr0/TheCalcMan.rar
|
|
|
|
|
Hi fellow coders,
Hope I'm posting in the right thread.
I'm trying to do a HTTP GET request but I get this error: Unable to read data from the transport connection.
Below is my code:
Dim web As New System.Net.WebClient
Dim stream As Stream = web.OpenRead(URI)
Dim reader As StreamReader
reader = New StreamReader(stream)
strResult = reader.ReadToEnd
Note I cant do POST as the URI does not support that.
Thank you in advance.
|
|
|
|
|
I would suggest the first thing you do is try a different URI, because if a different one works, then your problem is with the specific URI you're trying to talk to, and the answer will lie in what they support, not in your code.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Hi,
I have a csv file which I can access and read into a dataset with the following code:
Dim conn As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & IO.Path.GetDirectoryName(strFilePath) & ";" & _
"Extended Properties=""text;HDR=Yes;FMT=Delimited"";")
Dim FileName As String = IO.Path.GetFileName(strFilePath)
Dim da As New System.Data.OleDb.OleDbDataAdapter("SELECT * FROM " & FileName, conn)
Dim ds As New DataSet
da.Fill(ds, "FileImport")
This works great for the most part but it seems to be converting one of the fields to an integer instead of a decimal. For example: In my csv file I have a PreCost and PostCost column. I've opened up the csv file with notepad and verified that one of the rows contains 1.46 for the PreCost and 1.46 for the postcost. However, using the above code, the dataset after the fill command contains 1.46 for the Precost value and 1 for the postCost value.
I could understand this if the PreCost and PostCost both were converted to 1 but why would only one field get read correctly.
Here's a sample row from the csv file:
01111111 ,01111111111 ,Joe Bloggs ,xxxxxxxx ,18-MAY-2009,11:59:46,01111111111 ,NON GEOGRAPHIC NUMBER ,PEAK ,00:08:34 ,0 ,Y ,N ,1.46 ,1.46 ,
You will notice the 1.46 values for PreCost and PostCost. There is also a blank field after PostCost.
Anyone got any ideas why the dataAdapter.Fill method would do this? and how I get around it?
Updated: I've just tried saving a new csv file with just the row above and headers. The "1.46" values were converted correctly. So why would the original file not process any of the PostCost columns correctly? It appears that everything after the "." is ignored rather than rounded. ie. 1.85 would be converted to 1 and 0.85 would be 0??
|
|
|
|
|
This does seem strange, and I can't tell you for sure why this is happening. There a few thoughts I'd like to think out loud though:
- In you sample csv file does the PostCost field contain values without decimals or a decimal point ? Perhaps the dataAdapter converts the whole column to integer, because the first, last, or majority of rows contain values without a decimal point.
- Is something in the extended properties in the connection string causing this behavior?
- Using Select * leaves the determination of the data types entirely to chance. Using it is only useful if the contents of the files can differ. A work around for this would be to specifically name each column in the query, and if necessary use some sort of cast statement to force the data type.
- If on the other hand, your file does not contain column headers, you probably assign them in the datagrid, or dataview, or somewhere. In the same place you can almost always also determine the data type.
I hope these thoughts help you to find a solution.
Cheers, Johan
My advice is free, and you may get what you paid for.
|
|
|
|
|
Hi,
Thanks for your reply. I think your on to something with this:
"- In you sample csv file does the PostCost field contain values without decimals or a decimal point ? Perhaps the dataAdapter converts the whole column to integer, because the first, last, or majority of rows contain values without a decimal point."
I tried a file with the first record having the postCost value of 0. I still couldn't recreate the error. However, I did manage to replicate the error if I created lots of rows with the initial value of 0 and then the last row having the value 1.46. So I am assuming the first so many rows get scanned to determine a datatype.
So, I need to find a way of specifying the dataType. I'm not sure how I would do this in the Select statement though? I did find this link though which uses a Schema.ini file to force the datatypes. So I will try this:
http://www.aspdotnetcodes.com/Importing_CSV_Database_Schema.ini.aspx[^]
thanks for your help. Much appreciated.
|
|
|
|
|
I am having trouble with the getModuleFileNameEx api call in a VB.net application. It will not return to me the filepath of the currently active window. Any idea what i am doing wrong?
The only output i get currently from lpFileName is ?rmMain (as in the title of the form with a ? in place of the first letter), and that only lasts for one execution of the code. If it is executed more than once per run, it just outputs blank afterwards.
nextWnd = GetForegroundWindow()
' Gets title and path of the active window
GetWindowText(nextWnd, lpString, lpString.Capacity)
modTest = GetModuleFileNameEx(Process.getCurrentProcess, nullWnd, lpFileName, 500)
Thanks,
John
|
|
|
|
|
I'm reading a SQL database created by a PHP app, and there are several columns of data that were Base64 encoded and serialzed. Using VB.NET I'm easily able to take a string of data and decode it, but then have a problem de-serializing the data. I need to do this all in memory, so I use a MemoryStream. But when this is run, it says the stream is not in a binary format.
I'm missing a step or two here???
System.Runtime.Serialization.SerializationException was unhandled
Message="The input stream is not a valid binary format. The starting contents (in bytes) are: 4F-3A-34-3A-22-69-74-65-6D-22-3A-34-3A-7B-73-3A-32 ..."
Source="mscorlib"
Imports System.Runtime.Serialization
Imports System.Runtime.Serialization.Formatters
Imports System.BitConverterImports System.Text.RegularExpressions
Public Class Form1
Private Sub testing()
Dim OrderItem as string
Dim ByteArray() As Byte
Dim DecodedString As String
Dim DeSerializedString as String
OrderItem = "Tzo0OiJpdGVtIjo0OntzOjI6ImlkIjtpOjM0NjA3MztzOjg6InF1YW50aXR5IjtkOjE7czo3OiJvcHRpb25zIjthOjA6e31zOjU6InJlZ2lkIjtzOjA6IiI7fQ=="
ByteArray = System.Convert.FromBase64String(OrderItem)
DecodedString = System.Text.Encoding.ASCII.GetString(ByteArray)
DeserialzedString = Deserialize(DecodedString)
End Sub
Private Function Deserialize(ByVal DecodedString As String) As String
Dim bf As New Binary.BinaryFormatter()
Dim ms As New IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(DecodedString))
Return bf.Deserialize(ms)
End Function
End Class
|
|
|
|
|
You're not going to get a binary deserialization of a PHP serialized object. If the data was just string data that was serialized using something like an XML Serializer in PHP, then you've got something, but binary, there's no method that I'm familiar with that will get .NET to deserialize a binary object that was no serialized with .NET.
|
|
|
|
|
I've been experimenting with this and cannot get the results I want. I have two multiline textboxes. I want them to resize as the form expands. However, when the form expands, the top textbox will grow over the bottom one. I would like to keep spacing the same. Do I need to write a formula in the form.resize method or what?
Thanks in advance.
|
|
|
|
|
|
On the top multiline textbox, turn off the "bottom" on the anchor setting while.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
Thanks for the answers. I'm still experimenting, but the really helped push me in the right direction.
|
|
|
|
|