473,782 Members | 2,439 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting a Specific Object - System.Data.Sql DbType.Int

Hi Team,

I am having a string as "System.Data.Sq lDbType.Int". Now I want to convert
this string type to actual type to use with my Command object Parameter
Creation. How I will convert this string to the type object ?.
Thanks in advance
Nov 15 '05
11 4240
Thanks Budy.... I solved the Problem. I have to cast it again, Like,

(SqlDbType) Enum.Parse(type of(SqlDbType), "Int")
Once Again Thanks for the guidence.

"Vinod I" <Vi****@PMAM.co m> wrote in message
news:uO******** ******@TK2MSFTN GP09.phx.gbl...
Hi,

I think that will solve my problem. But if possible, please let me know
the exact synatax .
I tryed like below. But not working,
objCmd.Paramete rs.Add(objDRTmp["ParamName"].ToString(),
Enum.Parse(type of(SqlDbType), "Int"), intSize)

Thank U.

"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com...
Vinod I <Vi****@PMAM.co m> wrote:
It will be always of "SqlDBTypes ". At runtime I will be getting the type information as "String" and I want to add parameters to my command object accordingly. Please let me know the solution as early as possible.


In that case, just strip off the bit before the last dot (or just get
your uses to pass "Int" instead) and use
Enum.Parse(type of(SqlDbTypes), name)

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


Nov 15 '05 #11
Vinod I <Vi****@PMAM.co m> wrote:
I think that will solve my problem. But if possible, please let me know
the exact synatax .
I tryed like below. But not working,
objCmd.Paramete rs.Add(objDRTmp["ParamName"].ToString(),
Enum.Parse(type of(SqlDbType), "Int"), intSize)


Sorry - you'll need to cast the result of Enum.Parse to SqlDbType:

SqlParameter param = new SqlParameter
(objDRTmp["ParamName"].ToString(),
(SqlDbType)Enum .Parse(typeof(S qlDbType), "Int"),
intSize);

objCmd.Paramete rs.Add(param);

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
9781
by: muralidharan | last post by:
WebForm1.aspx Code: <%@ Register TagPrefix="ComponentArt" Namespace="ComponentArt.Web.UI" Assembly="ComponentArt.Web.UI" %> <ComponentArt:TreeView id="TreeView1" Height="520" AutoPostBackOnNodeMove="false" DragAndDropEnabled="true" NodeEditingEnabled="False" KeyboardEnabled="true" CssClass="TreeView" NodeCssClass="TreeNode" SelectedNodeCssClass="SelectedTreeNode" HoverNodeCssClass="HoverTreeNode" NodeEditCssClass="NodeEdit"
1
3664
by: studen77 | last post by:
Thanks to anyone in advance who can help :) Ok, I know this is a far stretch, but what I'm trying to do is to cast a System.object as one of the SqlDbType enumerations (SqlDbType.Int, -.NVarchar, etc.) Is this anyway possible? Through inheritance, or anything?
0
1570
by: Dica | last post by:
i'm getting an error when trying set my dataAdapter's selectCommand. the sqlStatement is a storedProc which takes parameters, so it's constructed as: sqlSelectCommand1.CommandText = ""; sqlSelectCommand1.CommandType = System.Data.CommandType.StoredProcedure; sqlSelectCommand1.Connection = sqlConnection1; sqlSelectCommand1.Parameters.Add(new
0
1909
by: zhaoJian | last post by:
Here it is my code ,but it can't update the database.How to do it ? In _UpdateUnit event, I can not get the original value to @Original_UnitID,so I set a hidden column named LabelKey.But It don't update the database.My server is SqlServer 2000. using System; using System.Collections;
0
2131
by: Roman | last post by:
I'm trying to create the form which would allow data entry to the Client table, as well as modification and deletion of existing data rows. For some reason the DataGrid part of functionality stops working when I include data entry fields to the form: I click on Delete or Edit inside of DataGrid and get this error: "Error: Object doesn't support this property or method" If I remove data entry fields from the form - DataGrid allows to...
1
1602
by: Manuel Canas | last post by:
Hello there, I am using the VB.NET Standart Edition compiler and I would like to know if this is not supported on this edition. This is just a testing code from a book that I'm trying here and it builds with no problem, but when I run it I get and error. This is the code snipet;
1
2775
by: tedqn | last post by:
Problem: - Stored procedure input parameters data type specific (SqlDbType.Int, SqlDbType.VarChar,etc). - Form submitted value in TextBox, DropDownList, etc are all string type (I guess). Some maybe empty. I need a function that would grab the string value and dynamically convert to the corresponding data type specific sql parameter OR DBNull.Value. The problem is that I have to specifically specify what data type the function will...
1
1632
by: KhoaNguyen | last post by:
i have two classes..one is a base and the other is inherited from the base class Below is my code -------ConnectionProvider class--------------------- using System; using System.Collections.Generic; using System.Text; using System.Configuration;
2
2432
by: preeti13 | last post by:
Hi guys i am here with my another probelm please help me.trying insert the value into the data base but getting the null value error .I am getting thsi error Cannot insert the value NULL into column 'EmployeeID', table 'Accomplishments.dbo.Accomplishment'; column does not allow nulls. INSERT fails. The statement has been terminated. and my code is this using System; using System.Collections;
0
9639
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10311
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10146
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9942
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8967
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6733
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5509
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2874
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.