473,322 Members | 1,614 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Is this the correct method???

111 100+
hi all,

i have a query...



Dim objListItem As ListItem

objListItem = CType(cbProjectName.SelectedItem, ListItem)

Try

Dim myselectquery As String = "SELECT IsNull(1,0) FROM tbl_staff_assignments " _
& "WHERE sta_project_id_fk =(SELECT pr_project_id_pk FROM tbl_projects WHERE tbl_projects.pr_project_location = @PLoc) " _
& "AND sta_category_id_fk = cbCategoriesName.SelectedItem = 1 "

cmSQL.Parameters.Add("@PLoc", objListItem.ToString)

cnSQL = New MySqlConnection
cnSQL.ConnectionString = connect.ConnectionString



cmSQL.Connection = cnSQL
cmSQL.CommandText = myselectquery


Try
cnSQL.Open()

Dim Val As Integer


Int(Val = cmSQL.ExecuteScalar(myselectquery))

If (Val = 0) Then

MsgBox("Manager available in this project.. select other project or insert new project")


Else

insert record




is this the correct way..??

when im trying to execute this.... im getting an error:

"Object reference not set to instance of an object"

plz help..
Jul 17 '07 #1
7 1197
kenobewan
4,871 Expert 4TB
Is there a line number? Suggest you debug the code.
Jul 17 '07 #2
TRScheel
638 Expert 512MB
cmSQL and cnSQL are not declared
Jul 17 '07 #3
rhepsi
111 100+
Is there a line number? Suggest you debug the code.

hey...

im getting error at this line...

cmSQL.CommandText = myselectquery

then???

hey plz i need help...

thnx..
hepsi..
Jul 18 '07 #4
kenobewan
4,871 Expert 4TB
And have you referenced cmSQL?
Jul 18 '07 #5
rhepsi
111 100+
And have you referenced cmSQL?

hey thnx.... nw its working..

But im getting other error:

Cast from type string to double is invalid... at line:

If ("sta_category_id_fk") = 1 Then

plz help..
thnx
Jul 18 '07 #6
kenobewan
4,871 Expert 4TB
Should sta_category_id_fk be in quotes?
Jul 18 '07 #7
rhepsi
111 100+
Should sta_category_id_fk be in quotes?
Hey ure right...


If i give my code like this:

cmSQL.ExecuteScalar()
Dim sta_category_id_fk As Integer

If sta_category_id_fk = 1 Then
MsgBox("Manager already avaiable .. plz select other project or insert new project..")

Else
AddNewStaff()
End If



U know wat the result is: For every category... it is displaying message "Manager already avaiable .. plz select other project or insert new project.."

infact for only manager category(if its availble then it shd dispaly tht message not when other category is seelecetd)


plz help..
thnx...
Jul 18 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: ST | last post by:
Hello, I will be posting 2 errors that I just can't seem to figure out (I'll put them in different posts). I have looked all over the internet, and I still can't figure these out! This webapp was...
13
by: Kenneth Baltrinic | last post by:
This isn't a problem from the standpoint that its easy to work around. However, I am very currious as to the correctness of this behavior. I am developing an MDI application. In the application...
3
by: Dave | last post by:
I have a piece of hardware connected via serial port. I need to send a variety of commands to the box and route the responses back from the receive thread to the correct method call. So e.g. I...
2
by: Brian Henry | last post by:
Tell me if this is the correct reasoning for this situation. I have two objects, both are structures and have identical data in the structure. I place one into a queue object, now if i do a...
4
by: **Developer** | last post by:
I looked at MSDN and a book and both described the naming convention for parameters should be camel style. The book used camel, except for Set (ByVal Value as ...) There it always used an...
1
by: brett | last post by:
I have several pages that need to use a method I've written that streams in text file content. I added a CS file to my website and named it Utilities. It has two static methods. One method reads...
15
by: Andyza | last post by:
I'm looking at another developers code and I'm now confused about the correct way to close a database connection and destroy the object. I would normally do it this way: Set conn =...
6
by: stephen.cunliffe | last post by:
Hi, I'm looking for opinion/facts/arguments on the correct nesting of UL, OL, & LI elements. For example, this is what I want (unordered list): * Item 1 * Item 2 * Item 3
4
by: yumbelie | last post by:
Hi, I've got an issue where I've created a prototype that contains 2 methods, and a few private variables. The first method simply registers the second method to be an event handler for the...
2
by: Andy Champ | last post by:
We have a class with something that, simplified, looks like this: template <typename Tclass foo { T beyondAllReaching; // In VC2005, this works OK template <typename Ufriend void...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.