|
Hi. I am trying to figure out how to write a select statement that will retrieve all entries that have a certian letter combination in. EG: If the user enters "a" it will retrieve all words starting with an "a". if he enters "ad" it will return all words stsrting with "ad" etc. Please advise
|
|
|
|
|
This is a very basic SQL question. I suggest picking up a beginners book on SQL Server and working through it.
All you have to do is add a WHERE clause using the LIKE operator:
SELECT field1, field2, fieldn, ... FROM table WHERE somefield LIKE 'ab%'
This will return all entries starting with the letters "ab" in some field you chose.
|
|
|
|
|
|
I'm calling a function in an unmanaged DLL. It is returning data as unsigned integers. I am using Marshal.ReadInt32() to marshal the data. I am getting an "Arithmetic overflow" exception when it trys to put the signed integer data into the managed unsigned integer variable:
Dim uiData as UInt32 = Marshal.ReadInt32(ipBuffer)
The exception only happens when the data has the most significant bit set (the "sign" bit). If Marshal.ReadUInt32() existed, obviously I would use that. Since it does not exist, I am marshaling the four bytes individually using Marshal.ReadByte() and constructing the unsigned integer. Is there a better way to do this?
|
|
|
|
|
VFaul wrote: Dim uiData as UInt32 = Marshal.ReadInt32(ipBuffer)
The exception only happens when the data has the most significant bit set (the "sign" bit). If Marshal.ReadUInt32() existed, obviously I would use that. Since it does not exist, I am marshaling the four bytes individually using Marshal.ReadByte() and constructing the unsigned integer. Is there a better way to do this?
No, not really. You're reading a four byte value as signed 32-bit integer (31 bits plus the sing bit), which means the number read can be a negative number, not positive. When the conversion to Unsigned is attempted, it can't convert a negative number, so you get the exception.
You can convert any number of bytes using the BitConverter class. You still need to read the four bytes into an array, but you can use the BitConverter.ToUInt32[^] method to do this, probably easier than you're doing it now.
|
|
|
|
|
Yes, I understand why the exception is occurring.
What baffles me is that there aren't unsigned marshaling methods: Marshal.ReadUInt16(), ReadUIn32(), and ReadUInt64()!? I'm being forced to do four ReadByte() calls when one call to ReadUInt32() is all I would need.
|
|
|
|
|
VFaul wrote: What baffles me is that there aren't unsigned marshaling methods: Marshal.ReadUInt16(), ReadUIn32(), and ReadUInt64()!? I'm being forced to do four ReadByte() calls when one call to ReadUInt32() is all I would need.
Yep. After looking at the code for the Marshal class, ReadInt32 method, it's sort of obvious why. That method has but a single line of code that calls a function, ND_RI4 , exported by mscoree.dll . This function reads a 4 byte value and returns an I4, or Int32. The only other exported functions that do this are:
ND_RI2 - Returns a 16-bit signed integer
ND_RI4 - Returns a 32-bit signed integer
ND_RI8 - Returns a 64-bit signed integer
and
ND_RU1 - Returns a single byte
There are counterpart functions that write values too, modeled after these "read" version. Sadly, it boils down to the CLR doesn't natively support what you want to do.
I also looked into the possibility of using Marshal.ReadIntPtr, which returns a processor width pointer. On any non-x64 version of Windows, this always maps to a 32-bit unsigned integer. But, there is no conversion supplied to go from an IntPtr to a UInt, only a conversion to Int32 exists.
|
|
|
|
|
Hi All,
I am doing Installaion build for a Vb Based Application.In the automation procedure of this,I need to change the version Compatability(In Project\Project Properties\Component) from outside.Means I need to change it programmatically.
Means in the automation procedural steps,it will take the project automatically,change the compatability and then save the project.
Can Anyone help me to solve this problem.......
Thanks In Advance,
Jeeva.
|
|
|
|
|
I am writing a VB 6 program that shd run on the network. A user has to login before using the program. Now, I want to prevent multiple user login using one user account. It shdn't allow or prevent a user to login whilst his/her account is in use. I am using MS SQL Server 2000 Database.
Please, can anyone help me with this? I would be very grateful if you could help me with this.
|
|
|
|
|
Once the user is logged in you can mark him/her as logged-in in your database. Whenever the user tries to log in you can check against the database if he is already logged-in or not.
"Legacy code" often differs from its suggested alternative by actually working and scaling.
—Bjarne Stroustrup
|
|
|
|
|
Hi. How do I change the title bar heading in a form dynamically in code?
|
|
|
|
|
use below statement in the code
form1.text=" Title Here!"
Rajesh B --> A Poor Workman Blames His Tools <--
|
|
|
|
|
Hi. thanks.... I had to use me.text but thanks for the help.
|
|
|
|
|
I have a textfile which has lots of records.I want to open the text file in excel.I used the codings
below.What is the problem is all the columns in the textfile seems to be in the same column of
excel.
for example
i have records in text file as follows
name location Phno
lily chennai 234567
all the three columns are in the same column of excel.
Codings used
===========
Private Sub OpenTextFile()
Dim oExcel As New Excel.Application
oExcel = CreateObject("Excel.application")
oExcel.Visible = True
oExcel.Workbooks.Open("C:\sample\test.txt")
End Sub
|
|
|
|
|
Seems reasonable to me. Excel treats each line of text as cell.
Opening the file programatically does not invoke the import wizard you are probably used to. You will need to parse each line yourself if you want it split to discreet cells
|
|
|
|
|
There is an option in excel to set tab delimiters but i dont know how to set in codings.If anybody know how to do it pls help me.
modified on Wednesday, March 19, 2008 4:28 AM
|
|
|
|
|
AFAIK you have to do this manually during the load. I do not know if you can invoke the Excel tools (they need user interaction) when processing from code.
Your could use split and write each node to a cell manually
|
|
|
|
|
|
Hi.. I have a form that is accessed from a previous form by clicking either of 2 buttons. If for example button1 on form 1 is clicked it accesses a form2 with one set of details. If button 2 on form1 is clicked it accesses form2 but with a different set of details. I need to determine which button was clicked on form 1 so I can load the correct data on form 2. Please Assist
|
|
|
|
|
When you instantiate the form you can pass the button id or a value for each button to the sub new
in the calling form
oFrm = New frmPFElement(iID)
Constructor in the called form
Sub New(ByVal iID As Integer)<br />
<br />
' This call is required by the Windows Form Designer.<br />
InitializeComponent()<br />
<br />
' Add any initialization after the InitializeComponent() call.<br />
mvID = iID<br />
End Sub
|
|
|
|
|
I'll try that thanks.
|
|
|
|
|
Just set the click event for both buttons then do a select case on the sender object of the event like below:
<br />
private sub form_Click(ByVal send as System.Object, ByVal e as System.EventArgs)Handles form1Btn.Click, form2Btn.Click<br />
Select Case sender.name<br />
Case "form1"<br />
'do something here<br />
Case "form2"<br />
'do something else<br />
End Select<br />
End Sub<br />
That should do it. I did this for an airplane seating chart. Worked great. Each seat was really a button and once it was taken I put a big red X on it to show that is was not avaliable.
Tom
Tom Wright
tawright915@gmail.com
|
|
|
|
|
My table has 4 fields that Name, Age, Date and Town. Data can add and delete. Data from Date field are displayed onto the ComboBox by DISTINCT SQL keyword. I wanna retrieve the data from Name, Age and Town by choosing a data from ComboBox that contains date data. I will display my data onto a DataGridView. When I run my project no data display noto the DataGridView. But I get for 18/3/08, error format 12:00:00AM is displayed in Message box and for other date I get correct format.
My code is following...
Private Sub cbbDate_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cbbDate.SelectedIndexChanged
On Error Resume Next
Dim dt As Date
cbbDate.Text = cbbDate.SelectedItem
If Not cbbDate.Text = "All Date" Then
dt = CDate(cbbDate.SelectedItem).ToString("M,d,yyyy")
MsgBox(dt)
DisplayReport("SELECT * FROM tblSave WHERE Date=" & dt & " ORDER BY Name ASC")
Else
ShowAll()
End If
Date Field Format in the table is 'Short Date'. ( month, day, year)
Date format from ComboBox is ( day, month, year).
|
|
|
|
|
phowarso wrote: But I get for 18/3/08, error format
phowarso wrote: Date Field Format in the table is 'Short Date'. ( month, day, year)
Date format from ComboBox is ( day, month, year).
Well, that's obviously the issue then.
phowarso wrote: DisplayReport("SELECT * FROM tblSave WHERE Date=" & dt & " ORDER BY Name ASC")
Don't do this. Parameterise your query, then this sort of thing will take care of itself.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I am trying to put some info from the database and datatable into a data grid and I get an error on the phone number fields when trying to display the info in the dataGrid control.
Here is the error I get.
It says it can't store the info in the column. The type is Int 32, expecting Int32.
In the database in this column I am using a bigint in sql server express 2005.
Here is my code.
Dim dt As New DataTable()
Dim dr As DataRow
For Each row As DataRow In dtStud.Rows
dr = dt.NewRow()
dr(0) = row("stud_name")
dr(1) = row("stud_par_name")
dr(2) = row("stud_id")
' get student instruments
Call studentInstruments(Convert.ToInt32(row("stud_id")))
' create counter
Dim intCount As Integer = 1
For Each row2 As DataRow In dtStudInst.Rows
If intCount = 1 Then
strInst = Convert.ToString(row2("less_instrument"))
Else
strInst += ", " & Convert.ToString(row("less_instrument"))
End If
Next
dr(3) = row("stud_phone")
dr(4) = row("stud_cell")
dr(5) = strInst
dt.Rows.Add(dr)
Next
Can anyone tell me why it expects int32 when I am using a Long for the data table column.
The error says the following:
Value was either too small or large for an int32. Couldn't store <9098791232>in stud_phone column. Expected type is Int32.
stud_phone is the name of the database field. I get this error on program start up which means it is in sub loadStudentList().
Do you thinkitmight help to convert the vlue from the database to a string?
|
|
|
|