|
ooopss... i didn't follow ur code as is and used Defaultview instead creating new views for both grids.
now its working fine. thanks a bunch.
a happy customer
Follow your goals, Means will follow you ---Gandhi---
|
|
|
|
|
good. i'm glad it helped.
take it easy.
-jim
|
|
|
|
|
Hi All,
Is there any way that I can parse and validate a SQL query (like the Parse Query function in Query Analyzer of SQL Server) before actually executing it in .NET code? Thanks a lot!
Tony Cheng
|
|
|
|
|
I think your looking for this,
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_set-set_47eh.asp
Call New SqlCommand("Set parseonly on", connection).ExecuteNonQuery()
Hope that helps
|
|
|
|
|
Yep. It does work. But when I tried to run:
SET PARSEONLY ON
--some query here
SET PARSEONLY OFF
it does not like it and execute the query in the middle. But thanks a lot for your reply. It's good enough.
Tony
|
|
|
|
|
Just a note Tony,
I don't think you have to use the OFF because
the SET would only last the duration of the query, the SET would release as soon as you come back to the next line of code.
I'm glad it worked for you.
|
|
|
|
|
You are right. If you use a different connection each time(e.g. new a connection for each query), you need not set PARSEONLY off. But if you use the same connection for different queries, you need to set it off before you DO want to execute any query. Thanks again for your message.
Tony
|
|
|
|
|
Hi,
I am trying to write an app where the users would have to define for
instance company departments where employer would work. These departments are
store in my database. In the user interface, where the user has to enter the
employers, I am trying to use the propertygrid. For the department I want to
use a dropdownlist filled with the options from the database. I have got a
typeconverter that converts a sting into a dropdownlist, but this is only
hardcoded. I am not able to pass a string created from my database into the
typeconverte. The converter looks like this
Public Class DropDownConv
Inherits StringConverter
'Override the GetStandardValuesSupported method to indicate that this
object supports a standard set of values.
'Override the GetStandardValues method and return a
StandardValuesCollection filled with our custom list.
Dim _States As String() = New String() {"Alabama", "Alaska", _
"Arizona", "Arkansas", _
"California", "Colorado", "Connecticut", "Delaware", _
"Florida", "Georgia", _
"Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", _
"Kentucky", "Louisiana", "Maine", "Maryland",
"Massachusetts", _
"Michigan", "Minnesota", "Mississippi", "Missouri",
"Montana", _
"Nebraska", "Nevada", "New Hampshire", _
"New Jersey", "New Mexico", _
"New York", "North Carolina", "North Dakota", _
"Ohio", "Oklahoma", _
"Oregon", "Pennsylvania", "Rhode Island", "South Carolina", _
"South Dakota", "Tennessee", "Texas", "Utah", _
"Vermont", "Virginia", _
"Washington", "West Virginia", "Wisconsin", "Wyoming"}
Public Overloads Overrides Function GetStandardValuesSupported( _
ByVal context As ITypeDescriptorContext) As Boolean
Return True
End Function
Public Overloads Overrides Function _
GetStandardValues(ByVal context As _
System.ComponentModel.ITypeDescriptorContext) _
As System.ComponentModel.TypeConverter.StandardValuesCollection
Return New StandardValuesCollection(_States)
End Function
'Finally override the GetStandardValuesExclusive method. When set to
false, it changes the dropdown list to Combo box (editable). If set to true,
then its a simple list box (Read only).
Public Overloads Overrides Function _
GetStandardValuesExclusive(ByVal context _
As System.ComponentModel.ITypeDescriptorContext) _
As Boolean
Return True
End Function
End Class
Can you give me some ideas on how to continue?
Thanks
David J
|
|
|
|
|
I need to write a .mat file (MATLAB file) from visual basic. Are there any scripts out there that can do this? I am not a professional programmer, so any help here would be greatly appreciated. Last time i ask this question, i got a reference to a website explaining the format of a .mat file, but i am still alittle lost.
thanks
|
|
|
|
|
Can you translate the post below into: "I need to write a .mat file (MATLAB file) from visual basic."
Using ActiveX in Visual Basic to connect to MATLAB
I am trying to connect to MATLAB trough a Visual Basic GUI progam. I found the documentation on ActiveX for MATLAB, and it had a very simple example in VB. However, when i try to run this simple execution, i get an error.
Code:Dim Matlab As Object
Dim res As String
Set Matlab = CreateObject("Matlab.Application")
res = Matlab.Execute("surf(peaks)")
Error: ActiveX component can't creat object
this occurs at the the set Matlab line.
Any suggestions? I am far from a pro at programing. Are there better examples of connecting VB to MATLAB out there? I couldn't find one. Or any better suggestions on how to go about connecting to MATLAB? (I learn best from examples)
Funny, my crystal ball couldn't either!
- the devil made me do it..., I apologize to everyone else on CP.
|
|
|
|
|
Actually, i was refering to a post before this one! either way, it was not witty in any sense. I figured if you spent your time to reply, it would at least be funny. good job picking on someone new to this stuff.
thanks ANONYMOUS tough guy! can't even use your id, huh?
|
|
|
|
|
"I figured if you spent your time to reply, it would at least be funny. good job picking on someone new to this stuff." - murphypa
And I figured if you spent your time in Researching your problem from (28 May '04) with all the good help and answers you've got from this VB.Net forum so far, you wouldn't be "someone new to this stuff" anymore.
Your own history, and post's, suggest all you want is someone to do the work for you.
9:51 26 Aug '04
Re: .MAT files from Visual Basic (Again) - murphypa
Visual Basic / VB.NET (Programming Forums)
9:47 26 Aug '04
Re: .MAT files from Visual Basic (Again) - murphypa
Visual Basic / VB.NET (Programming Forums)
16:34 25 Aug '04
.MAT files from Visual Basic (Again) - murphypa
Visual Basic / VB.NET (Programming Forums)
14:21 25 Aug '04
Re: Using ActiveX in Visual Basic to connect to MATLAB - murphypa
Visual Basic / VB.NET (Programming Forums)
12:04 25 Aug '04
Re: Using ActiveX in Visual Basic to connect to MATLAB - murphypa
Visual Basic / VB.NET (Programming Forums)
10:50 25 Aug '04
Using ActiveX in Visual Basic to connect to MATLAB - murphypa
Visual Basic / VB.NET (Programming Forums)
12:10 23 Aug '04
How do you write .MAT files from Visual Basic - murphypa
Visual Basic / VB.NET (Programming Forums)
11:19 1 Jun '04
calling MATLAB from VB6 - murphypa
Visual Basic / VB.NET (Programming Forums)
14:49 28 May '04
how do you create a .mat file in VB6? - murphypa
Visual Basic / VB.NET (Programming Forums)
|
|
|
|
|
murphypa wrote:
I need to write a .mat file (MATLAB file) from visual basic. Are there any scripts out there that can do this?
Well, what format is your data in currently? There are many translation scripts for many things. However, if the data is in some format internal to your company then you are going to have to do the work.
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
|
|
|
|
|
The data is in ascii format and has data and strings that i need to send to matlab through a .mat file. I think i could use anything along these lines, even if it's not exactly what i need i think i could learn enough to write what i need from a good example.
Thanks
|
|
|
|
|
murphypa wrote:
ascii format
First, ASCII isn't a format, it is a character encoding. This is a common misunderstanding / mistake. But for someone who is new to the field it can cause confusion, so I thought I'd better clear that up first.
How is your text file structured? Is it comma delimited, like this?
"Field1","Field2",123,45.6
Or tab delimited? (like the previous example but with tabs instead of commas). Or is it fixed width fields, like this?
Field1 Field2 123 45.6
F1-Row2 F2-Row2 4567 12.98
F1-Row3 F2-Row3 19984 98.765 Or similar with zero padding for numbers?
Better yet. Do you have a document that describes the structure?
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
|
|
|
|
|
I'm using vb.net with sql server. Wanted to know the least painful way of creating an Excel sheet or CSV populating it with data either from a datagrid or datatable or anyway, really.
Thanks for any help!
|
|
|
|
|
"least painful" -LOL
here's a few ways:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;306022
|
|
|
|
|
I'm new at this, and I don't recognize a way that matches my setup. I already have a connection established and I like to use stored procedures. Below is how I retrieve data from the stored procedure. How do I go from here into an Excel sheet or CSV?
***********************************************************
Dim ClientView As DataTable = DirectCast(Session("ViewClients"), DataTable)
ClientView = New DataTable()
Dim sc As New SSS.BusinessLogicLayer.Mgmt()
ClientView = sc.GetClientView(Session("FAgentIDView"), Session("RB"))
Session("ViewClients") = ClientView
Dim dr As DataRow = DirectCast(Session("ViewClients"), DataTable).Rows(0)
**********************************************************
Public Shared Function GetClientView(ByVal FAgentID As String, ByVal RB As String) As DataTable
Dim ds As DataSet = SqlHelper.ExecuteDatase(ConfigurationSettings.AppSettings(LTCMgmt.SSS.Web.Global.CfgKeySSSString), "usp_tp_MailViewSetup", FAgentID, RB)
Dim dt As New DataTable()
dt.Columns.Add("ClientID")
dt.Columns.Add("FName")
dt.Columns.Add("LName")
dt.Columns.Add("Address1")
dt.Columns.Add("Address2")
dt.Columns.Add("City")
dt.Columns.Add("State")
dt.Columns.Add("PostalCode")
dt.Columns.Add("Voice")
dt.Columns.Add("Fax")
dt.Columns.Add("Mobile")
dt.Columns.Add("EMail")
dt.Columns.Add("BirthDate")
dt.Columns.Add("MaritalStatus")
Dim r As DataRow
Dim workRow As DataRow
For Each r In ds.Tables(0).Rows
workRow = dt.NewRow
Dim nOne As String
nOne = r("BirthDate")
nOne = Replace(nOne, " 12:00:00 AM", "")
workRow("ClientID") = r("ClientID")
workRow("FName") = r("FName")
workRow("LName") = r("LName")
workRow("Address1") = r("Address1")
workRow("Address2") = r("Address2")
workRow("City") = r("City")
workRow("State") = r("State")
workRow("PostalCode") = r("PostalCode")
workRow("Voice") = r("Voice")
workRow("Fax") = r("Fax")
workRow("Mobile") = r("Mobile")
workRow("EMail") = r("EMail")
workRow("BirthDate") = nOne
workRow("MaritalStatus") = r("MaritalStatus")
dt.Rows.Add(workRow)
Next
Return dt
End Function
***************************************************
|
|
|
|
|
I can't test this with your data source of course on my end, and you'll have to de-bug it over there too, but it should give you an idea of how I would go about getting it to go.
You could call somthing like this on your return from GetClientView with your DataTable dt.
Private Function OpenWorkbook(ByVal dt As DataTable)
Dim oExcel As New Excel.Application
Dim oBook As Excel.Workbook
Dim oBooks As Excel.Workbooks
Dim oSheet As Excel.Worksheet
Dim oSheets As Excel.Sheets
Dim oCells As Excel.Range
Dim dr As DataRow
Dim ary() As Object
Dim iRow As Integer, iCol As Integer
'Start a new workbook in Excel.
oExcel = CreateObject("Excel.Application")
oBook = oExcel.Workbooks.Add
oBook = oBooks.Item(1)
oSheets = oBook.Worksheets
oSheet = CType(oSheets.Item(1), Excel.Worksheet)
oSheet.Name = "First Sheet"
oCells = oSheet.Cells
'Output Column Headers
For iCol = 0 To dt.Columns.Count - 1
oCells(2, iCol + 1) = dt.Columns(iCol).ToString
Next
'Output Data
For iRow = 0 To dt.Rows.Count - 1
dr = dt.Rows.Item(iRow)
ary = dr.ItemArray
For iCol = 0 To UBound(ary)
oCells(iRow + 3, iCol + 1) = ary(iCol).ToString
Next
Next
'Save the workbook and quit Excel.
oBook.SaveAs(Application.StartupPath & "Book1.xls")
oSheet = Nothing
oBook = Nothing
oExcel.Quit()
oExcel = Nothing
GC.Collect()
End Function
Note:
Don't forget to add the Com reference to Excel10 in your Solution Explorer.
|
|
|
|
|
|
I'm pretty new to VB, .NET, and windows in general. I'm trying to write a simple app (VB .NET) that plays a wav file and gets notified when the playing is complete. I've been trying to use MCI with a callback function, etc. but I can't get it to work. Does anybody have any sample code for doing this in .NET? Is using MCI the best approach? Would it be better to use windows media player or directX, or ...?
thanks
|
|
|
|
|
Mentalis has a multimedia class I like to use it's more in the Intermediate catagory but, you may want to give it a look at:
http://www.mentalis.org/soft/class.qpx?id=1
|
|
|
|
|
I like the Mentalis media a lot. I've used it several times previously and it works pretty good for me.
Clickety[^]
Aaron Eldreth
TheCollective4.com
My Articles
I hereby boycott this poll. Really....
- Leppie
|
|
|
|
|
I have about 6-10 different moderately complex queries that are returning a count.
I am wanting to figure out the best, most efficient method for running those queries and displaying the counts either in a table or a datagrid type view.
Currently, I have a function that gets all the SQL Commands that I need and places them in and array.
I setup a data adapter and fill a separate table on a dataset for each Count query I have.
TO display I set a table's specific cells to show the dataset.tables("whatever").row(0).Item(0)
It seems to take quite a long time for this method....
Does someone know something better??
I am still a beginner so any advice would be helpful.
Thanks
cavall
"Nothing is at last sacred, but the integrity of your own mind."
"What lies behind us and what lies before us are nothing compared to what lies within us." - Ralph Waldo Emerson
|
|
|
|
|
From your description, is would appear that 99% of the time it takes to come up with the final result is being taken up by the SQL queries themselves. The code to put the final table with the results is nearly nothing. If these queries are static, meaning you always use the same set of queries the same way, then you might want to look into have the SQL Server run a stored procedure that runs all of your queries for you and returns a small table with the results you want. Then, you would only have to write code to handle the returned table of results, bind your datagrid to it, and not worry about dataset.tables("whatever").row(0).Item(0) .
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|