我正在尝试使用Excel VBA在Access表的新列中修改数据类型的字段大小。我有以下代码可用:
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <limits.h>
using namespace std;
typedef struct node
{
int data, min;
struct node *next;
}node;
bool isempty(node *head)
{
return !head;
}
void display(node *head)
{
while(head)
{
cout<<head->data<<"-->";
head=head->next;
}
cout<<"\n";
}
int get_min(node *head)
{
return head->min;
}
int peek(node *head)
{
if(isempty(head))
return INT_MIN;
return head->data;
}
void push(node **head_ref, int data)
{
node *new_node;
new_node=(node*)malloc(sizeof(node));
new_node->data=data;
if((*head_ref)==NULL || data <= get_min((*head_ref)))
{
new_node->min=data;
}
else
{
new_node->min=(*head_ref)->min;
}
new_node->next=(*head_ref);
(*head_ref)=new_node;
}
int pop(node **head_ref)
{
if(isempty((*head_ref)))
return INT_MIN;
int c=(*head_ref)->data;
node *temp=(*head_ref);
(*head_ref)=(*head_ref)->next;
free(temp);
return c;
}
int main()
{
node *head=NULL;
push(&head, 3);
push(&head, 0);
push(&head, 1);
display(head);
cout<<get_min(head);
return 0;
}
我的问题是我的一些数字需要Double格式,有些需要Long Integer格式。我找不到任何关于如何使用TEXT字段长度来指定的文档。有什么想法吗?
答案 0 :(得分:1)
好的,我明白了。这简直太简单了。
InsertDataCommand = "ALTER TABLE " & TableName & " ADD COLUMN " & ColumnName & " "
Select Case DataType
Case Is = "TEXT"
InsertDataCommand = InsertDataCommand & DataType & "(" & DataLength & ")"
Case Is = "LONG INTEGER"
InsertDataCommand = InsertDataCommand & DataType
Case Is = "DOUBLE"
InsertDataCommand = InsertDataCommand & DataType
Case Is = "MEMO"
InsertDataCommand = InsertDataCommand & DataType
Case Is = "DATE"
InsertDataCommand = InsertDataCommand & DataType
End Select
AccessObject.CurrentProject.Connection.Execute (InsertDataCommand)
我认为Number类型必须指定Text类型所做的相同类型的语句,但是它没有。