|
I found my answer. I needed commands.
|
|
|
|
|
I am trying to get table names from different types of databases. I have successfully acquired table names from a MS Access database. Now I am writing code to get table names from a SQL server database. I am having trouble and don't know what I am doing wrong. Can someone help me. The only thing I can find online about this is the Select statements and not all that I need.
Code:
Dim databasestruct As Database<br />
Dim connectionstring As String<br />
Public radioDataset As DataSet = New DataSet<br />
Public dt As DataTable = New DataTable("table") <br />
<br />
<br />
connectionstring = "Data Source=.\SQLEXPRESS;AttachDbFilename=" + database + ";Integrated Security=True;Connect Timeout=30;User Instance=True"<br />
<br />
Dim connection As New SqlClient.SqlConnection(connectionstring)<br />
<br />
connection.Open()<br />
<br />
Dim str As String = "SELECT name FROM(dbo.sysobjects)WHERE xtype = 'U'"<br />
Dim adapt As SqlDataAdapter = New SqlDataAdapter(str, connection)<br />
radioDataset.Tables.Add(dt)<br />
adapt.Fill(dt)
When I run this I get the following error on the last line. Incorrect syntax near ')'
What am I doing wrong?
|
|
|
|
|
The select statement should be:
SELECT name FROM dbo.sysobjects WHERE xtype = 'U'
Note the space between FROM and dbo.sysobjects and between dbo.sysobjects and WHERE .
SQL is not forgiving about missing spaces.
|
|
|
|
|
vb.net/visual studio 2003
i put a picturebox into a panel1 with panel1.autoscroll=true.
now, whenever the user moves the scrollbars of this panel1, i want a second panel besides this panel1 to change its location according to panel1's autoscrollposition. how do i do this? there seems to be no event for change of autoscrollposition.
|
|
|
|
|
Your description isn't very clear. You've got TWO panel controls, I'm assuming, side-by-side on the form, and you want when one panel is scrolled, the other should also scroll to the same position?? What does the PictureBox has to do with this?
|
|
|
|
|
in the picturebox i am drawing a bitmap on which i paint my data. the picturebox's size is the same as the bitmap. the picturebox is in panel1 (with autoscroll=true) to allow the user to scroll the picture since it is bigger then the screen. that works all fine.
but:
in the second panel besides the one holding the picturebox i am painting some stuff that is related to the stuff in the picturebox an should therefor always be seen on the same height as the picturebox.
like in excel where you can fix some columns on the left, and when you scroll to the right, those fixed columns will stay in place to show e.g. the rows' name/number/whatever.
but my bitmap is also taller than the screen, and i want the side-panel, on which i paint these rows' names, to change its height (think it is better to repaint the names on the new height) according to panel1.autoscrollposition's y-value.
--> but to repaint the content of this panel on the right position i need an event to trigger this repaint, an event that catches when the user fiddles around with panel1's scrollbar.
so just this event is what i need.
|
|
|
|
|
If I understand you correctly, all you would have to do is handle the Scroll event of the 1st panel and make any changes you need to the values that the 2nd panel's painting code uses to show it's contents.
|
|
|
|
|
yeah, that's what i want to do. but i don't know how to handle the scroll-event. can't find a scroll-event.
|
|
|
|
|
klappklapp wrote: but i don't know how to handle the scroll-event. can't find a scroll-event.
There are two ways to have Visual Studio create the framework of the event handler for you.
The first is to open up the form designer and click on your 1st panel. Then, go to the Properties window and click on the little yellow lightning bolt to show the available events for the panel. Double-click on line that says "Scroll".
The second method is to open up the code editor for the form your panel is on. At the top of the editor window, just under the window tabs, there are two drop down boxes. In the left drop down, click on your 1st panel object. Then in the right drop down, you'll find all the available events for the panel listed. Just click on "Scroll"...
|
|
|
|
|
i know, how to create an event's framework.
but there is no scroll-event for panels in visual studio 2003! or am i dumb or blind or something?
|
|
|
|
|
ok, think i found out myself.
thanks anyway.
simply created a new class which inherits from panel, create a public event "scroll", override wndproc, catch WM_VSCROLL and WM_HSCROLL, and raise the scroll event.
|
|
|
|
|
klappklapp wrote: but there is no scroll-event for panels in visual studio 2003!
I didn't notice that you said that in your original post. No, the 2003 version of the Panel doesn't have a Scroll event, you what you did was correct. Create your own version of the Panel, adding support to look for Scroll messages.
|
|
|
|
|
I wonder if anyone can help me with the following problem.
I am trying to update a grid element within a array
e.g.grdGridArea.Item(x - 1, 6) = 50
This element was added in another procedure using InsertAt.
The array is populated no problems until I get to this element where I then get the following error;
Run-time exception thrown : system.data.dataexception.
This is driving me nuts so is there anyone that can tell me how this is happening then fix it
It is properly something simple.
|
|
|
|
|
You've given the exception type, but you failed to tell us what the exception's Message is. Without that, it's pretty difficult to tell you anything useful.
|
|
|
|
|
I am getting an err.number = 5
The problem is when I try and assign a double value to the element I get this err number. Works fine with the others but crashes as above.
Hope this help.
|
|
|
|
|
Got the following error message....
An unhandled exception of type 'System.Data.DataException' occurred in system.data.dll
|
|
|
|
|
None of this is the contents of the Message property of the exception you're getting.
Err is the old VB's error object, that's just about useless. You should NOT be using ON ERROR .... in your VB.NET code. You should be using Try/Catch blocks instead. Comment out the ON ERROR .... lines in your code so you can see a proper exception message.
On top of that, how about posting the code snippet that throws the exception.
|
|
|
|
|
I do not use err or ON ERROR as I use try etc. I just done err hoping for any clues.
For x = 1 To dTotalGridLines
dRate= Val(txtRate.Text)
grdArea.Item(x - 1, 6) = dRate <===== THIS IS WHERE IT CRASHES
dValue1 = Val(grdArea.Item(x - 1, 5)) * Val(txtRate.Text)
grdArea.Item(x - 1, 7) = dValue1 <===== THIS IS WHERE IT CRASHES
Next x
It is a straight forward statement. I reckon it could maybe be when I insertat. Could it be that I am not formatting the element at insertion.
|
|
|
|
|
You still haven't answered my question. What is the exact exception message??
The old Err.Number says that it's an "Invalid procedure call or argument". Since the old meanings are so vague, I can only guess that the column your trying to assign a value to is not a number type or you're trying to assign a floating point value to an integer type column.
|
|
|
|
|
Sorry, I am still a bit rusty with the .Net stuff. I done the following which returned the following. Hope this is what you require.
? ex
{System.Data.DataException}
[System.Data.DataException]: {System.Data.DataException}
HelpLink: Nothing
InnerException: Nothing
Message: "Cannot set Rate."
Source: "System.Data"
StackTrace: " at System.Data.DataRowView.SetColumnValue(DataColumn column, Object value)
at System.Data.DataColumnPropertyDescriptor.SetValue(Object component, Object value)
at System.Windows.Forms.DataGridColumnStyle.SetColumnValueAtRow(CurrencyManager source, Int32 rowNum, Object value)
at System.Windows.Forms.DataGrid.set_Item(Int32 rowIndex, Int32 columnIndex, Object value)
at Valuation.frmPropertyDetails.cmdApply_Click(Object sender, EventArgs e) in C:\Code\NET\project\frmArea.vb:line 4602"
TargetSite: {System.Reflection.RuntimeMethodInfo}
|
|
|
|
|
Sorry, I am still a bit rusty with the .Net stuff. I done the following which returned the following. Hope this is what you require.
? ex
{System.Data.DataException}
[System.Data.DataException]: {System.Data.DataException}
HelpLink: Nothing
InnerException: Nothing
Message: "Cannot set Rate."
Source: "System.Data"
StackTrace: " at System.Data.DataRowView.SetColumnValue(DataColumn column, Object value)
at System.Data.DataColumnPropertyDescriptor.SetValue(Object component, Object value)
at System.Windows.Forms.DataGridColumnStyle.SetColumnValueAtRow(CurrencyManager source, Int32 rowNum, Object value)
at System.Windows.Forms.DataGrid.set_Item(Int32 rowIndex, Int32 columnIndex, Object value)
at Valuation.frmArea.cmdApply_Click(Object sender, EventArgs e) in C:\Code\NET\project\frmArea.vb:line 4602"
TargetSite: {System.Reflection.RuntimeMethodInfo}
|
|
|
|
|
It looks like the Rate column in your dataset is ReadOnly, or the value you passed isn't of the proper type and cannot be converted to the type expected by the Rate column.
|
|
|
|
|
How to create folder ?
How to test exist folder or file(duplicate) ?
VB.Net
|
|
|
|
|
Use System.IO namespace which contains the function to create folder and files in VB.NET
The System.IO.File.FileExist function used to check for an existing file it will return the boolean value.
With Regards
Yogesh Agarwal
|
|
|
|
|
But i would like to know the function which can create folder.
Thank you for your help.
Best Regards,
VB.Net
|
|
|
|